-
LUA Example
02/19/2018 at 21:58 • 0 commentsAnd the same example for the NodeMCU LUA:
function read_channel(channel) i2c.start(0) i2c.address(0, 0x35, i2c.TRANSMITTER) i2c.write(0, bit.bor(bit.lshift(channel, 1), 0x61)) i2c.start(0) i2c.address(0, 0x35, i2c.RECEIVER) high = i2c.read() low = i2c.read() i2c.stop() return bit.bor(bit.lshift(bit.band(high, 0x0f), 8), low) end i2c.setup(0, 1, 2, i2c.SLOW) while (true) do print(read_channel(0)) end
-
Python Example
02/19/2018 at 21:46 • 0 commentsThe same example in MicroPython for the ESP8266:
import machine def read_channel(i2c, channel): if not 0 <= channel <= 11: raise ValueError() data = i2c.readfrom_mem(0x35, 0x61 | (channel << 1), 2) return ((data[0] & 0x0f) << 8) | data[1] i2c = machine.I2C(-1, sda=machine.Pin(4), scl=machine.Pin(5)) while True: print(read_channel(i2c, 0))
-
Arduino Example
02/19/2018 at 19:26 • 0 commentsThis is an example Arduino sketch that keeps reading from channel 0 and printing the result on the serial console.
#include <Wire.h> #define ADC_I2C_ADDRESS 0x35 uint16_t readChannel(uint8_t channel) { if (channel >= 12) { return 0; } Wire.beginTransmission(ADC_I2C_ADDRESS); Wire.write((channel << 1) | 0x61); Wire.endTransmission(false); Wire.requestFrom(ADC_I2C_ADDRESS, 2); uint8_t high = Wire.read(); return ((high & 0x0f) << 8) | Wire.read(); } void setup() { Wire.begin(); Serial.begin(9600); } void loop() { Serial.print(readChannel(0)); }
-
Finally
09/27/2017 at 12:07 • 0 commentsSo the PCBs from DirttyPCBs never arrived. They made me wait for them for 8 weeks, and then sent a replacement, which also never arrived. After further 4 weeks of waiting, I thanked them, closed the support ticket, and ordered the PCBs at Seeed Studio. Whatever new shipping method they have now, it doesn't seem to be working in my country very well. I don't think I will be ordering from them anymore.
On the bright side, the PCBs from Seeed just arrived, and I have assembled and tested one, so they should appear in the Tindie store very soon (I just need some time to assemble and test a bunch).
-
Waiting for the PCBs
07/07/2017 at 22:00 • 0 commentsThe chips have already arrived, the Tindie page is prepared, now I'm just waiting for the PCBs to arrive. It's been over 6 weeks already, and I'm starting to get nervous about them. Dirty PCBs never took that long before, except for that time around the Spring Festival, of course, but that's expected.
-
Production PCBs Ordered
05/29/2017 at 05:17 • 0 commentsHaving gotten the prototypes to work, I panelized and ordered the PCBs for the "production" version:
This time I removed one of the tabs, to make sure the board outline is cut correctly. Then I went to my favorite Chinese store looking for the chips to populate this with, and found that I can no longer order them at the price I found them initially. I guess I will wait a little bit and see if they re-appear.
-
That Was Quick
05/28/2017 at 06:24 • 2 commentsAt last a project that went smoothly for a change. The MAX1238 chips arrived, and I soldered them to the PCBs and they seem to be working just fine at first sight. I was a bit worried about the chips being too small when I saw them, but they are fine.
I wrote a very simple MicroPython library to handle this shield:
class MAX123x: def __init__(self, i2c, address=0x35): self.i2c = i2c self.address = address self.reset() def reset(self): self.i2c.writeto(self.address, b'\x80') def read(self, channel): if not 0 <= channel <= 11: raise ValueError() data = self.i2c.readfrom_mem(self.address, 0x61 | (channel << 1), 2) return ((data[0] & 0x0f) << 8) | data[1]