Error in AnalogRead from A0 compared to a multimeter with tinyduino processor

varotodfc

  • Newbie
  • *
    • Posts: 2
    • View Profile
Hello,

I have a project that intends to charge  a 500mAh battery  and  power the  tinyduino  board and sensors using solar panels that produce nominally 5V and 30 mA. In addition, I want to know what panel is charging and what is the current running through them.  Since the solar panels are in parallel the voltage drop is the same for all of them, so I decided to use Ge diodes in order to minimize the power loss.

At this point I'm running tests with just one solar panel. Apparently, due to the diode the solar panel is asked to provide 6V, therefore I introduced a voltage divider using 2 resistors of 100 kOhms and later I substituted them by 2 of 10 kOhms. My problem is that when I measure the voltage drop in one of the resistors using a multimeter it indicates 2.5V and using the AnalogRead(A0) it shows 2.83V. (See image attached for the wiring)


My code for the TX is:
Code: [Select]
#include <Wire.h>
#include <SPI.h>
#include "RH_RF22.h"

#ifndef ARDUINO_ARCH_SAMD
#include <EEPROM.h>
#endif

#if defined(ARDUINO_ARCH_SAMD)
  #define SerialMonitorInterface SerialUSB
#else
  #define SerialMonitorInterface Serial
#endif

RH_RF22 rf22(7,3);

int sensorValue;

void setup() {
  // put your setup code here, to run once:
  SerialMonitorInterface.begin(115200);
  //pinMode(5, OUTPUT);
  //pinMode(A1, INPUT);
  pinMode(LED_BUILTIN, OUTPUT);

  rf22.init();
  rf22.setTxPower(RH_RF22_TXPOW_20DBM);
  rf22.setModemConfig(RH_RF22::GFSK_Rb125Fd125);
 

  while(!SerialMonitorInterface);
}

void loop() {
  // put your main code here, to run repeatedly:
      sensorValue = analogRead(A0);
      float voltage = float(sensorValue)/1023.*5.;
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
     

      SerialMonitorInterface.println(voltage);

      uint8_t data[2];
      //int voltage2=getVCClevel();
 
      //data[0]=voltage2>>8;   // bus voltage in 0.01V increments
      //data[1]=voltage2;
      data[0]=sensorValue>>8;
      data[1]=sensorValue;
      rf22.send(data, sizeof(data));//send return packet ot transmitter
      rf22.waitPacketSent();
  delay(1000);
}

The code for the RX is:
Code: [Select]
#include <Wire.h>
#include <SPI.h>
#include "RH_RF22.h"

RH_RF22 rf22(7,3);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.begin();
  while(!Serial);

  if (!rf22.init())
    Serial.println("init failed");
  rf22.setTxPower(RH_RF22_TXPOW_20DBM);
  rf22.setModemConfig(RH_RF22::GFSK_Rb125Fd125);//FSK_Rb2_4Fd36

}

void loop() {
  // put your main code here, to run repeatedly:
  if (rf22.waitAvailableTimeout(50))//wait for up to 50ms, see if there's a response
  {
    uint8_t buf[RH_RF22_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (rf22.recv(buf, &len))//receive packet into buffer
    {
      int voltage1 = buf[0]<<8 | buf[1];
      float result =float(voltage1)/1023*5;
      Serial.println(result);
    }
  } 

}

Thank you in advance.


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 239
    • View Profile
Hey there,

I'm not completely clear on the question, but I thought that I would mention a voltage divider will divide the voltage - resulting in less voltage rather than more voltage. There's a good tutorial here that includes a calculator to calculate the expected voltage drop: https://learn.sparkfun.com/tutorials/voltage-dividers/all

It sounds like you want to boost the 5V voltage up to 6V for the diode? You can add more solar panels in series and put them under bright lighting, or you could consider getting a boost converter to up the voltage output. That being said, most Ge diodes require just 0.3V to become active (forward-biased), compared to Si diodes needing 0.7V. Do you have a datasheet or more info on the particular diode?

Let me know if I am misunderstanding any of your project goals!

RĂ©na


 

SMF spam blocked by CleanTalk