Help with SGM58031 ADC Edgebox-ESP-100

Hello.

I recently got an Edgebox-ESP-100, I try to connect with the internal SGM58031 ADC to get a 4-20mA reading but no success.

Unfortunately there are no examples of the application of the Edgebox-ESP-100 peripherals, can you help me to share some? I use Arduino IDE by the way.

Thank you.

Hi, because i have no response i search a solution.

Use the Adafruit ADS1115 library, it works well,you have 24921 points of adc using 2x gain.

This is very good resolution for general purposes, but i search how obtain the 65k and 32k points.

1 Like

Thanks for the tip.
Gain 2x when to saturation over16 mA on channel 0,2 in my case. Gain 1 work for me for all channels. See below my calibration table, channel 0 and 3 are 30% more counts than 1 and 2. The results are very consistence, that is a big plus, so each channel should use their own engineering units / count factor.
#include <Adafruit_ADS1X15.h>
Adafruit_ADS1115 AI; // analog inputs
void setup(void) {
Serial.begin(115200);
AI.setGain(GAIN_ONE); // set gain to all channels
if (!AI.begin()) {
Serial.println(“Failed to initialize AIs.”);
while (1);
}
}
void loop(void) {
Serial.print("Analog Input Ch0 counts ");
Serial.println( AI.readADC_SingleEnded(0));
Serial.print("Analog Input Ch1 counts ");
Serial.println(AI.readADC_SingleEnded(1));
Serial.print("Analog Input Ch2 counts ");
Serial.println(AI.readADC_SingleEnded(2));
Serial.print("Analog Input Ch3 counts ");
Serial.println(AI.readADC_SingleEnded(3));
delay(2000) ;
}

image

1 Like

For the Analog PWM outputs DAC below code works for me.

// set the PWM pin number
const int AO0 = 42; // corresponds to GPIO42
const int AO1 = 41; // corresponds to GPIO41
// setting PWM properties
const int freq = 5000;
const int Channel0 = 0;
const int Channel1 = 1;
const int resolution = 8;

void setup(void) {
// setup analog outputs
// configure LED PWM functionalities
ledcSetup(Channel0 , freq, resolution);
ledcSetup(Channel1 , freq, resolution);
// attach the channel to the GPIO to be controlled
ledcAttachPin(AO0, Channel0 );
ledcAttachPin(AO1, Channel1 );
}
void loop(void) {
ledcWrite(Channel0 , 255); // set to max 255, duty cycle 0-255
ledcWrite(Channel1 , 255); // set to max 255, duty cycle 0-255
}

1 Like

Hi og2023,

I am having problems getting the SGM58031 to work. I have been working on my own code with an I2C bus instance set to match the SDA and SCL pins used for the internal I2C in the ESP100, but no response. I copied and pasted your code from above and I have the same result. I have nothing connected to the AI inputs, I am just trying to get a response from it (i.e. a bit count at 0mA input) to demonstrate that it is working. Is there anything else you had to do to get this to work which is not included in your post?

Hi theriddleofthesands

Check this post:

Hi theriddleofthesands,

I have the digital input and outputs power on pins 1,2,3 , 23 and 24 as per the unit side picture pin out. Power was 24 Vdc. Nothing else. Perhaps your unit counts 0 at 0 mA. Try a bigger gain, it may work.

Many thanks for your reply. When I run your code I get the “Failed to initialize AIs.” so it is the ADC not responding rather than a gain issue. I will try powering the digital I/O as you did - perhaps this also supplies feeds the ADC.