Non-Linearities ADC Reading on ESP32 - microcontroller

I'm using ADC pin in ESP32 WROOM to determine the voltage reading from them (GPIO34, GPIO35, GPIO36, GPIO39) but the reading is not accurate aka non-linear.
What I have done is:
I take the actual reading using a multimeter and compare to what the ESP32 reads on those pins by using a potentiometer by varying the voltage on that pin (from 0.1V -> 3.3V based on the ADC reading)
I put those numbers into an excel sheet to plot the error in the following columns :
ADC_READING_VOLTAGE | MULTIMETER_READING | ERROR (MULTIMETER_READING - ADC_READING_VOLTAGE)
Then I get a trendline equation from the error plot and add the error margin to the ADC_READING_VOLTAGE so that I could actually get the real value of the reading (MULTIMETER_READING)
voltage_reading = analogRead(adc_pin)/4095 *3.3V // to get the actual reading
The method that I've tried though gives a slightly better result, but still not good enough (the reading is still off by +- 0.2V)
Has anyone deal with this before? Any suggestions are welcomed.

I'll need your header files to give you a clear solution.
I also came across this issue when I used the WiFi.h everything seems to work fine without WiFi.h, for some reason the ESP32 analog pins(13,12,14,4..) are HIGH while using WiFi.h that's why when you connect the sensors to these pins the value returned is 4095 which is the highest value, I got around this by changing the pins to pin 32, 34, 35, 36 & 39.

I figured it out by plotting 3 piecewise equation to solve the problem on excel, reduced the error margin around +-0.02V (although region >3.1V around +-0.05V).

Related

Trying to interface with an Aanderaa RCM9

I have an older Aanderaa RCM9 (https://epic.awi.de/id/eprint/45145/1/RCM9.pdf) that is missing its Data Storage Unit and its reader. They don't produce these anymore nor do they service the model. It would be a shame to toss an otherwise nice piece of equipment, so I thought to try and get a serial feed from the terminal or DSU output and log on an Arduino with an SD card. I have tried to connect with a TTL-RS232 converter, and there seems to be a consistent Tx from the instrument, it comes in batches, but reads out in CoolTerm as "............" I've tried different terminal configurations, and connections, but that's the best I get. Here's how it looks inside: https://imgur.com/a/xxCPUlQ
Any thoughts??
I am afraid that the output is the old Aanderaa PDC4 serial format where long pulses (81ms) represents zeros and short (27ms) represents ones in a 10 bit binary word framed in a 4 second window.

Any reason why my Tinkercad's arduino serial plotter is not updating?

The arduino should be reading different values as the signal is a sine wave. Tried using different signal frequency as well as different delay(), still shows a constant value. Any help is highly appreciated! Thanks!!
You are printing the value of A2 while you should be reading the pin itself.
Look for analogRead() to start with and if you intend to use much higher frequencies and perhaps need more precise information then consider using an interrupt.
You are not sending the actual reading of analog input. Your code should be something like
void loop(){
int adcRead = analogRead(A2);
Serial.println(adcRead);
delay(2);
}

Detect Telosb emission using USRP Source

I am using N210 USRP to have a RF spectrum around 2.4GHz range.
I have programmed two TelosB nodes and they are using RadioCoundLed to send and Receive signals
I have set the TelosB nodes at highest power level following the datasheet
I also made them fixed at a channel(26) around 2.48Ghz
I can see the Telosb nodes communication and the LEDS are blinking.
Now I should observe this in USRP RF spectrum. However I am observing nothing in Scope Sink. I have fixed the center freq in the 2.48 Ghz range.
Set the RX gain - 0
Sampling rate is 2M
Is it possible to even to observe it?
I guess I solved the problem. I was using the wrong daughter board. Now I am using the SBX board that can support 2.5Ghz range.

Modifying hex codes to produce a larger output

I was working on this project : http://elm-chan.org/works/sd8p/report.html
and I failed in every possible way from the start. Now that the .Hex files have been uploaded, and the fuses written, when I plugged the SD card in, nothing happened. Nothing at all. Directly asking for a solution might be impossible here as I have no idea what went wrong. So instead I tested the speaker's positive connection with the arduino serial plotter, and I found some interesting results. The output gave some cool irregular pattern of waves,similar to what I would expect from a sound output. But there was no sound, and I suspect that it was because of the output size being too small.(60/1023 is around 0.06 volts, 200/1023 is around 0.2 volts and the bigger output at 500++ levels out, so it shouldn't produce a sound.)
So now I would like to ask whether I can change the fuses of the .hex file(or the hex file itself, but its big.) to produce a larger output. I have not much understanding in hex files or even AVR devices, so any hep at all would be useful.
Thanks in advance.
the graphs
Please let me know if any other information is needed.
Your voltage output on a GPIO pin is limited to your supply voltage, so no you probably can't fix your problem by changing the software or the fuse bits. Depending on your current supply voltage, you might be able to crank that higher, which would increase your voltage output of the PWM, but the supply voltage can only go so high without damaging the chip.
That being said, you need to disconnect the amp and speaker from the AVR and probe the output pin of the PWM and make sure that it is actually producing a signal on that pin. The plots that you posted with that amplitude look like they are nothing but random electrical noise to me.

Quadricopter + arduino+mpu6050(gyro+oscillo) +PID

so I'm trying to creat a quadricopter with an arduino and gyroscope mp6050 and this with PID algorithme (using arduino PID,mpu library) so I make everything work separately but when it comes to use PID I don't know how to do it which one will be the input or setput ... I'm confused on how I can use gyroscope information and brushless information and other information to make my quadri fly ... thank you
It sounds like you need a better understanding of what PID does. Here is a great article about real world implmentation of PID http://eas.uccs.edu/~cwang/ECE4330F12/PID-without-a-PhD.pdf
It follows this code from AVR's website exactly (they make the ATMega32p microcontroller chip on the UNO boards) PDF explanation and Atmel Code in C
A PID controller is a feedback control loop.
The input ("Command" on the diagram) is the desired position, in your case this is what you want the gyroscope to read.
The "Output" is a control signal. It will tell your brushless motors (the "Plant") what to do to achieve the desired position.
The Feedback (input/output) We then use our "Sensors" to read the actual position. In your case this is the gyroscope data
Now the PID controller takes the error = desired position - actual position and uses the error to create the next command. The overall goal is to drive the error down to 0, in other words desired position = actual position The exact details of your PID coefficients are based on your specific setup and usually they must be tuned manually in order to achieve desirable results (see the links provided for more details).
Loooking at the Arduino PID Library Documentation shows that they have easy methods to set KP, KD, KI, input, output THey even have an autotune parameter that can automatically find your PID constants. Hope that helps, Good luck.

Resources