Espruino I2C specs #977
Replies: 16 comments
-
Posted at 2017-01-15 by CriscoCrusader I think I found the data I need, just not sure how to interpret it yet. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-15 by CriscoCrusader Tried adding a 10k resistor on the SDA line (between SDA and 3.3v) but no luck. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-15 by ClearMemory041063 The PICO page cites this datasheet link: http://www.espruino.com/datasheets/STM32F401xD.pdf I like the fuel gauge device for a battery. Hope you get it working. Try connecting a battery. The assumptions often wind up being the problem. These may also help: Section 9.5.4 of and http://www.espruino.com/Reference#I2C Looks like you have to send several bytes to get a response from the device. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-15 by Frida www.ti.com/lit/ds/symlink/bq27441-g1.pdf I don't know if PICO has clock stretching. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-15 by CriscoCrusader @frida, didn't have a pullup on SCL. Added it, still no luck though. Both resistors are 10k. @ClearMemory041063, waiting on the battery to arrive in the mail. The code in these I2C scanner scripts relies on reading 1 byte from a given address, so I've been using that approach. http://forum.espruino.com/conversations/278556/ These are some of the other devices that are also on the bus. On the LTC2631, CA1 and CA0 are both grounded, so the addresses would be 0xAA and 0xAB. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by ClearMemory041063 This code looks like it could be of use to you. It at least helps to sort out the various sequences of bytes that are needed to converse with the fuel gauge chip. Translating from C to JavaScript would need to be done. A starting point is to replace the #define variable 0xvalue with var variable= 0xvalue. For example then functions need to be redefined https://github.com/chintanp/i2c-charger/blob/master/BQ-27441-Gauge/c/gauge.c |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by @gfwilliams As other have said, it's just the F4's datasheet you need. I doubt there'll be any particular compatibility problems - we haven't had anything so far. I'd be pretty sure you need the pullup resistors, but you have those now. Have you checked the device address? It's stupid, but some systems use the address shifted left 1 bit, others use it shifted right one bit. I forget what Espruino is now, but that could potentially be tripping you up. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by CriscoCrusader Hi @gordon. I ran the I2C scanner script from the other thread, I don't get any positive results. If the address bits are shifted, wouldn't the scanner still find the devices? @ClearMemory041063, good find. Actually I think this wasn't that hard. But there's a few pieces I'm uncertain of. Is this line a function? So my guess is it becomes this: And the Looks like the Here's my first attempt at a rewrite. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by @gfwilliams Yes, the scanner should have found it (I think) - so you're basically getting I2C timeout errors whatever you do? Are you totally sure the SDA and SCL pins are connected properly and the right way around? I you don't have a logic analyser you could try sticking LEDs (pulled down from 3.3v) on the two pins, and making sure they're flashing when you do an I2C request? You could also try running I2C at a different baud rate? Sometimes things are a bit picky about it, but it's rare. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by CriscoCrusader @gordon, yes, just timeouts. What's the likelihood that the 3.3v pin on my board is only a reference voltage and doesn't power any of the slave devices? There's no other power being provided. I'm waiting on lithium ion batteries to arrive in the mail, which the board was QC'd with. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by @gfwilliams On the Pico? It'll be 3.3v at ~200mA or so - so should provide whatever you need. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by CriscoCrusader I mean my custom board. It has a JST connector for Li+ battery. I don't have a battery. I was thinking the slave devices would get power from 3.3v, but I'm thinking now the board only uses 3.3v as ref. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-16 by ClearMemory041063 Translating C to Espruino Javascript
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-26 by tage I am looking for information on if Espruino handles I2C clock stretching. I am running the Espruino wifi in master I2C mode at 100kHz and reading/writing to a slave that occasionally will stretch the clock. One workaround would be to run at slower clock but I wonder if I can run at 100kHz and handle clock stretching. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-28 by @gfwilliams You'd have to look at the reference manual for the STM32F411 to see for sure how it did it, but the hardware does handle it and I'm pretty sure it's enabled. The 411's I2C should be pretty much identical to the 401 (for the Pico) mentioned in this thread. Software I2C should also handle it, so you could try that and see what happens? https://github.com/espruino/Espruino/blob/master/src/jsi2c.c#L62 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-29 by tage Thanks Gordon, |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-15 by CriscoCrusader
I'm using the Espruino Pico and interfacing with a custom board that has several I2C devices, but things aren't working yet. I'm hoping someone can show me where I can find the Espruino's I2C hardware specs.
More Info:
I've been successful in tests using an arduino as a slave device. My simple test was to send a 12 bit value from the master and print to the serial monitor.
I'm wondering if there's a compatibility issue between the Espruino I2C and of the slave device(s) I2c. I haven't been able to find the Espruino's I2C hardware specs.
Some specs on my slave device(s):
VIH: Vpull-up * 0.7
VIL: 0.6
VOL: 0.6
One of the slave devices is a Li+ "Fuel Gauge":
http://www.ti.com/lit/ds/symlink/bq27441-g1.pdf
http://www.ti.com/lit/ug/sluuac9a/sluuac9a.pdf
I don't have a battery connected right now, but I assumed the circuit would be active on I2C since the 3v terminal on my board is connected to the 3v pin on the Espruino.
Thanks for reading.
Beta Was this translation helpful? Give feedback.
All reactions