The ESP8266 is a very nice chip, but the single 1V analog pin is not very useful. This shield is designed to add a dozen 12-bit analog pins.
Add 12 analog pins to the D1 Mini ESP8266 board
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
The ESP8266 is a very nice chip, but the single 1V analog pin is not very useful. This shield is designed to add a dozen 12-bit analog pins.
And 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
The 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))
This 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));
}
So 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).
The 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.
Having 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.
At 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]
Create an account to leave a comment. Already have an account? Log In.
Hi, I don't really have any libraries, because the reading from it is so simple, but I can see how they would be useful just to get people started quick. I will add example code for Arduino and the schematics etc. as soon as I'm back from vacation next week.
That would be great. I just need something to bring me up to speed on using your shield. Have a nice vacation.
Of course I forgot about all this as soon as I got back. I just saw this comment again now, and checked that I didn't add any examples. Sorry about that!
Become a member to follow this project and never miss any updates
By using our website and services, you expressly agree to the placement of our performance, functionality, and advertising cookies. Learn More
I received my boards today, anxious to fire one up. I see you have a python library, is it on GitHub? Would you happen to have a library for the Arduino IDE? Do you have schematics or hookup information available.
Thanks,
-Kirk