Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Solar Pannel and LiOn or Lipo

Solar Pannel and LiOn or Lipo

Scheduled Pinned Locked Moved Hardware
52 Posts 5 Posters 44.9k Views 9 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ceech
    Hardware Contributor
    wrote on last edited by ceech
    #18

    @epierre
    Does the basic functionality work? Do you receive any data from LTC4067?

    $_57.JPG

    Here is an example of RAW analogRead data from LTC4067.
    Notice the /CHRG change from High to Low. That indicates charging.

    analog input A1 on ATmega 328 is /CHRG signal from LTC4067
    analog input A0 on ATmega328 is battery voltage
    analog input A2 is solar cell voltage
    analog input A6 is input current ( I=V/R x 1000 )
    analog input A7 is battery charge current ( I=V/Rprog x 1000 )

    1 Reply Last reply
    0
    • epierreE Offline
      epierreE Offline
      epierre
      Hero Member
      wrote on last edited by
      #19

      Here is the code based on the other around:

      /*
        Vera Arduino BH1750FVI Light sensor
        communicate using I2C Protocol
        this library enable 2 slave device addresses
        Main address  0x23
        secondary address 0x5C
        connect the sensor as follows :
      
        VCC  >>> 5V
        Gnd  >>> Gnd
        ADDR >>> NC or GND  
        SCL  >>> A5
        SDA  >>> A4
        
        Contribution: idefix/epierre for ceech
       
      */
      #include <SPI.h>
      #include <MySensor.h> 
      #include <Wire.h> 				// I2C
      #include <BH1750.h>
      
      #define LTC4067_CHRG_PIN	A1		//analog input A1 on ATmega 328 is /CHRG signal from LTC4067
      #define batteryVoltage_PIN	A0		//analog input A0 on ATmega328 is battery voltage ( /2)
      #define solarVoltage_PIN	A2		//analog input A2 is solar cell voltage (/ 2)
      #define solarCurrent_PIN	A6		//analog input A6 is input current ( I=V/Rclprog x 1000 )
      #define batteryChargeCurrent_PIN	A7		//analog input A7 is battery charge current ( I=V/Rprog x 1000 )
      #define LTC4067_SUSPEND_PIN	9		//digital output D9 - drive it high to put LTC4067 in SUSPEND mode
      
      const float VccMin        = 1.0*3.5;  // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion.
      const float VccMax        = 1.0*4.2;  // Maximum expected Vcc level, in Volts. 
      
      #define LIGHT_SENSOR_ANALOG_PIN 3   // Digital input did you attach your soil sensor.  
      #define CHILD_ID_LIGHT 0   // Id of the sensor child
      #define BATT_CHILD_ID 10
      #define SOLAR_CHILD_ID 11
      
      // PIN Radio
      #define RADIO_CE_PIN    7       // radio chip enable
      #define RADIO_SS_PIN    8      // CS SS serial select
      
      float lastBattVoltage;
      float lastBattCurrent;
      float lastSolarVoltage;
      float lastSolarCurrent;
      int lastBattPct = 0;
      uint16_t lastlux;
      float VccReference = 3.3 ;				// voltage reference for measurement, definitive init in setup
      
      BH1750 lightSensor;
      MySensor  gw(RADIO_CE_PIN, RADIO_SS_PIN);;
      unsigned long SLEEP_TIME = 300*1000;  // sleep time between reads (seconds * 1000 milliseconds)
      MyMessage msg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
      MyMessage batteryVoltageMsg(BATT_CHILD_ID, V_VOLTAGE);		// Battery voltage (V)
      MyMessage batteryCurrentMsg(BATT_CHILD_ID, V_CURRENT);		// Battery current (A)
      MyMessage solarVoltageMsg(SOLAR_CHILD_ID, V_VOLTAGE);		// Solar voltage (V)
      MyMessage solarCurrentMsg(SOLAR_CHILD_ID, V_CURRENT);		// Solar current (A)
      
      int lastSoilValue = -1;
      
      void setup()  
      { 
       
        gw.begin();
      
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("Light Lux Sensor", "1.0");
        // Register all sensors to gw (they will be created as child devices)  
        gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
        gw.present(BATT_CHILD_ID, S_POWER);						// Battery parameters
        gw.present(SOLAR_CHILD_ID, S_POWER);					// Solar parameters
        
        // use VCC (3.3V) reference
        analogReference(DEFAULT);								// default external reference = 3.3v for Ceech board
        VccReference = 3.323 ;									// measured Vcc input (on board LDO)
        pinMode(LTC4067_SUSPEND_PIN, OUTPUT);					// suspend of Lion charger set
        digitalWrite(LTC4067_SUSPEND_PIN,LOW);   			//  active (non suspend) at start
      
        lightSensor.begin();
      }
       
      void loop()     
      {     
      
        sendVoltage();
        
        uint16_t lux = lightSensor.readLightLevel();// Get Lux value
        Serial.println(lux);
        if (lux != lastlux) {
            gw.send(msg.set(lux));
            lastlux = lux;
        } 
        
        // Power down the radio
        gw.sleep(SLEEP_TIME);
      }
      
      void sendVoltage(void)
      // battery and charging values
      {
      	// get Battery Voltage & charge current
      	float batteryVoltage = ((float)analogRead(batteryVoltage_PIN)* VccReference/1024) * 2;	// actual voltage is double
      	Serial.print("Batt: ");
      	Serial.print(batteryVoltage);
      	Serial.print("V ; ");
      	float batteryChargeCurrent = ((float)analogRead(batteryChargeCurrent_PIN) * VccReference/1024)/ 2.5 ; // current(A) = V/Rprog(kohm)
      	Serial.print(batteryChargeCurrent);
      	Serial.println("A ");
      
         
      	// get Solar Voltage & charge current
      	float solarVoltage = ((float)analogRead(solarVoltage_PIN)/1024 * VccReference) * 2 ;		// actual voltage is double
      	Serial.print("Solar: ");
      	Serial.print(solarVoltage);
      	Serial.print("V ; ");
      	// get Solar Current
      	float solarCurrent = ((float)analogRead(solarCurrent_PIN)/1024 * VccReference)/ 2.5;		// current(A) = V/Rclprog(kohm)
      	Serial.print(solarCurrent);
      	Serial.print(" A; charge: ");
      	Serial.println(digitalRead(LTC4067_CHRG_PIN)?"No":"Yes");
      	
      	// send battery percentage for node
      	int battPct = 1 ;
      	if (batteryVoltage > VccMin){
      		battPct = 100.0*(batteryVoltage - VccMin)/(VccMax - VccMin);
      	}
      	Serial.print("BattPct: ");
      	Serial.print(battPct);
      	Serial.println("% ");
      
      	gw.send(batteryVoltageMsg.set(batteryVoltage, 3));  		// Send (V)
      	gw.send(batteryCurrentMsg.set(batteryChargeCurrent, 6));  	// Send (Amps)
      	gw.send(solarVoltageMsg.set(solarVoltage, 3));  			// Send (V)
      	gw.send(solarCurrentMsg.set(solarCurrent, 6));  			// Send (Amps)
      	gw.sendBatteryLevel(battPct);
      }
      

      z-wave - Vera -&gt; Domoticz
      rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
      mysensors -&gt; mysensors-gw -&gt; Domoticz

      1 Reply Last reply
      0
      • epierreE Offline
        epierreE Offline
        epierre
        Hero Member
        wrote on last edited by epierre
        #20

        Batt: 3.94V ; 0.00A
        Solar: 0.18V ; 0.00 A; charge: No
        BattPct: 62%

        Batt: 4.10V ; 0.00A
        Solar: 0.55V ; 0.00 A; charge: No
        BattPct: 85%

        z-wave - Vera -&gt; Domoticz
        rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
        mysensors -&gt; mysensors-gw -&gt; Domoticz

        1 Reply Last reply
        0
        • epierreE Offline
          epierreE Offline
          epierre
          Hero Member
          wrote on last edited by epierre
          #21

          an idea maytbe, if I put sleep at 30 * 1000 it works, at 60 * 1000 infinite sleep... any idea ?

          (I observed that on both units). It also loas the battery ...

          Batt: 3.96V ; 0.00A
          Solar: 0.55V ; 0.00 A; charge: No
          BattPct: 65%
          send: 14-14-0-0 s=10,c=1,t=38,pt=7,l=5,st=ok:3.959
          send: 14-14-0-0 s=10,c=1,t=39,pt=7,l=5,st=ok:0.000000
          send: 14-14-0-0 s=11,c=1,t=38,pt=7,l=5,st=ok:0.545
          send: 14-14-0-0 s=11,c=1,t=39,pt=7,l=5,st=ok:0.000000
          send: 14-14-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:65
          22
          send: 14-14-0-0 s=0,c=1,t=23,pt=3,l=2,st=ok:22
          Batt: 3.97V ; 0.00A
          Solar: 0.48V ; 0.00 A; charge: No
          BattPct: 66%
          send: 14-14-0-0 s=10,c=1,t=38,pt=7,l=5,st=ok:3.966
          send: 14-14-0-0 s=10,c=1,t=39,pt=7,l=5,st=ok:0.000000
          send: 14-14-0-0 s=11,c=1,t=38,pt=7,l=5,st=ok:0.480
          send: 14-14-0-0 s=11,c=1,t=39,pt=7,l=5,st=ok:0.000000
          send: 14-14-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:66
          21
          send: 14-14-0-0 s=0,c=1,t=23,pt=3,l=2,st=ok:21

          z-wave - Vera -&gt; Domoticz
          rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
          mysensors -&gt; mysensors-gw -&gt; Domoticz

          C 1 Reply Last reply
          0
          • epierreE epierre

            an idea maytbe, if I put sleep at 30 * 1000 it works, at 60 * 1000 infinite sleep... any idea ?

            (I observed that on both units). It also loas the battery ...

            Batt: 3.96V ; 0.00A
            Solar: 0.55V ; 0.00 A; charge: No
            BattPct: 65%
            send: 14-14-0-0 s=10,c=1,t=38,pt=7,l=5,st=ok:3.959
            send: 14-14-0-0 s=10,c=1,t=39,pt=7,l=5,st=ok:0.000000
            send: 14-14-0-0 s=11,c=1,t=38,pt=7,l=5,st=ok:0.545
            send: 14-14-0-0 s=11,c=1,t=39,pt=7,l=5,st=ok:0.000000
            send: 14-14-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:65
            22
            send: 14-14-0-0 s=0,c=1,t=23,pt=3,l=2,st=ok:22
            Batt: 3.97V ; 0.00A
            Solar: 0.48V ; 0.00 A; charge: No
            BattPct: 66%
            send: 14-14-0-0 s=10,c=1,t=38,pt=7,l=5,st=ok:3.966
            send: 14-14-0-0 s=10,c=1,t=39,pt=7,l=5,st=ok:0.000000
            send: 14-14-0-0 s=11,c=1,t=38,pt=7,l=5,st=ok:0.480
            send: 14-14-0-0 s=11,c=1,t=39,pt=7,l=5,st=ok:0.000000
            send: 14-14-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:66
            21
            send: 14-14-0-0 s=0,c=1,t=23,pt=3,l=2,st=ok:21

            C Offline
            C Offline
            ceech
            Hardware Contributor
            wrote on last edited by
            #22

            @epierre
            Solar voltage seems a bit low. Can you raise it? And see if the charging takes place?

            1 Reply Last reply
            0
            • epierreE Offline
              epierreE Offline
              epierre
              Hero Member
              wrote on last edited by epierre
              #23

              sleep is the problem, it loads at 30s never above...

              Batt: 4.06V ; 0.00A 
              Solar: 2.56V ; 0.00 A; charge: No
              BattPct: 79% 
              
              Batt: 4.05V ; 0.00A 
              Solar: 3.38V ; 0.00 A; charge: No
              BattPct: 78%
              

              on the other:

              2015-07-05 20:32:40 14 10 1 0 38 4.024
              2015-07-05 20:32:40 14 10 1 0 39 0.001298
              2015-07-05 20:32:41 14 11 1 0 38 3.991
              2015-07-05 20:32:42 14 11 1 0 39 0.000000
              2015-07-05 20:32:42 14 255 3 0 0 74
              
              2015-07-05 16:24:08 14 10 1 0 38 3.953
              2015-07-05 16:24:08 14 10 1 0 39 0.001298
              2015-07-05 16:24:09 14 11 1 0 38 4.731
              2015-07-05 16:24:10 14 11 1 0 39 0.015577
              2015-07-05 16:24:10 14 255 3 0 0 64
              
              2015-07-05 18:55:40 14 10 1 0 38 4.050
              2015-07-05 18:55:40 14 10 1 0 39 0.061008
              2015-07-05 18:55:40 14 11 1 0 38 4.212
              2015-07-05 18:55:42 14 11 1 0 39 0.066200
              2015-07-05 18:55:42 14 255 3 0 0 78
              

              One one of the two units I have issues on radio:

              Batt: 4.05V ; 0.00A 
              Solar: 1.80V ; 0.00 A; charge: No
              BattPct: 78% 
              send: 15-15-0-0 s=10,c=1,t=38,pt=7,l=5,st=fail:4.050
              send: 15-15-0-0 s=10,c=1,t=39,pt=7,l=5,st=fail:0.001298
              send: 15-15-0-0 s=11,c=1,t=38,pt=7,l=5,st=ok:1.804
              send: 15-15-0-0 s=11,c=1,t=39,pt=7,l=5,st=fail:0.000000
              send: 15-15-0-0 s=255,c=3,t=0,pt=1,l=1,st=fail:78
              

              z-wave - Vera -&gt; Domoticz
              rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
              mysensors -&gt; mysensors-gw -&gt; Domoticz

              C 1 Reply Last reply
              0
              • epierreE epierre

                sleep is the problem, it loads at 30s never above...

                Batt: 4.06V ; 0.00A 
                Solar: 2.56V ; 0.00 A; charge: No
                BattPct: 79% 
                
                Batt: 4.05V ; 0.00A 
                Solar: 3.38V ; 0.00 A; charge: No
                BattPct: 78%
                

                on the other:

                2015-07-05 20:32:40 14 10 1 0 38 4.024
                2015-07-05 20:32:40 14 10 1 0 39 0.001298
                2015-07-05 20:32:41 14 11 1 0 38 3.991
                2015-07-05 20:32:42 14 11 1 0 39 0.000000
                2015-07-05 20:32:42 14 255 3 0 0 74
                
                2015-07-05 16:24:08 14 10 1 0 38 3.953
                2015-07-05 16:24:08 14 10 1 0 39 0.001298
                2015-07-05 16:24:09 14 11 1 0 38 4.731
                2015-07-05 16:24:10 14 11 1 0 39 0.015577
                2015-07-05 16:24:10 14 255 3 0 0 64
                
                2015-07-05 18:55:40 14 10 1 0 38 4.050
                2015-07-05 18:55:40 14 10 1 0 39 0.061008
                2015-07-05 18:55:40 14 11 1 0 38 4.212
                2015-07-05 18:55:42 14 11 1 0 39 0.066200
                2015-07-05 18:55:42 14 255 3 0 0 78
                

                One one of the two units I have issues on radio:

                Batt: 4.05V ; 0.00A 
                Solar: 1.80V ; 0.00 A; charge: No
                BattPct: 78% 
                send: 15-15-0-0 s=10,c=1,t=38,pt=7,l=5,st=fail:4.050
                send: 15-15-0-0 s=10,c=1,t=39,pt=7,l=5,st=fail:0.001298
                send: 15-15-0-0 s=11,c=1,t=38,pt=7,l=5,st=ok:1.804
                send: 15-15-0-0 s=11,c=1,t=39,pt=7,l=5,st=fail:0.000000
                send: 15-15-0-0 s=255,c=3,t=0,pt=1,l=1,st=fail:78
                
                C Offline
                C Offline
                ceech
                Hardware Contributor
                wrote on last edited by
                #24

                @epierre I'll ask @AWI, he may help.

                1 Reply Last reply
                0
                • AWIA Offline
                  AWIA Offline
                  AWI
                  Hero Member
                  wrote on last edited by
                  #25

                  Your circuit seems to be working correctly. I cannot figure out why the sleep time should influence the metering. I suggest you first test it with a minimal sketch to figure out this sleep issue.

                  1 Reply Last reply
                  0
                  • epierreE Offline
                    epierreE Offline
                    epierre
                    Hero Member
                    wrote on last edited by
                    #26

                    @AWI What should I keep as minimal ? also any idea about the radio hazard ? I've changed several antennae and it is either half wrong or "check wire"

                    z-wave - Vera -&gt; Domoticz
                    rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                    mysensors -&gt; mysensors-gw -&gt; Domoticz

                    AWIA 1 Reply Last reply
                    0
                    • epierreE epierre

                      @AWI What should I keep as minimal ? also any idea about the radio hazard ? I've changed several antennae and it is either half wrong or "check wire"

                      AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by
                      #27

                      @epierre in a minimal sketch I would remove have it only send one message and give it enough println's to debug via serial. Check the voltages with a meter and let it run with an increasing sleep time. It could be one of those 'bad radios' which are discussed here on the forum.

                      For the charging part: it only charges a partly empty cell and the charge voltage should be high enough to let it happen.

                      Debugging is where the fun starts (if you are able to solve it)..

                      1 Reply Last reply
                      0
                      • epierreE Offline
                        epierreE Offline
                        epierre
                        Hero Member
                        wrote on last edited by
                        #28

                        so the same without sensor nor mysensors... 30 secs fine 40 secs dead...

                        I've removed the radio chipset, same behavior...

                        /*
                         
                        #include <SPI.h>
                        
                        #include <Wire.h> 				// I2C
                        
                        
                        #define LTC4067_CHRG_PIN	A1		//analog input A1 on ATmega 328 is /CHRG signal from LTC4067
                        #define batteryVoltage_PIN	A0		//analog input A0 on ATmega328 is battery voltage ( /2)
                        #define solarVoltage_PIN	A2		//analog input A2 is solar cell voltage (/ 2)
                        #define solarCurrent_PIN	A6		//analog input A6 is input current ( I=V/Rclprog x 1000 )
                        #define batteryChargeCurrent_PIN	A7	//analog input A7 is battery charge current ( I=V/Rprog x 1000 )
                        #define LTC4067_SUSPEND_PIN	9		//digital output D9 - drive it high to put LTC4067 in SUSPEND mode
                        
                        const float VccMin        = 1.0*3.5;  // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion.
                        const float VccMax        = 1.0*4.2;  // Maximum expected Vcc level, in Volts. 
                        
                        #define LIGHT_SENSOR_ANALOG_PIN 3   // Digital input did you attach your soil sensor.  
                        #define CHILD_ID_LIGHT 0   // Id of the sensor child
                        #define BATT_CHILD_ID 10
                        #define SOLAR_CHILD_ID 11
                        
                        // PIN Radio
                        #define RADIO_CE_PIN    7       // radio chip enable
                        #define RADIO_SS_PIN    8      // CS SS serial select
                        
                        float lastBattVoltage;
                        float lastBattCurrent;
                        float lastSolarVoltage;
                        float lastSolarCurrent;
                        int lastBattPct = 0;
                        uint16_t lastlux;
                        float VccReference = 3.3 ;				// voltage reference for measurement, definitive init in setup
                        
                        
                        unsigned long SLEEP_TIME = 40*1000;  // sleep time between reads (seconds * 1000 milliseconds)
                        
                        int lastSoilValue = -1;
                        
                        void setup()  
                        { 
                         
                          Serial.begin(115200);
                          // use VCC (3.3V) reference
                          analogReference(DEFAULT);								// default external reference = 3.3v for Ceech board
                          VccReference = 3.323 ;									// measured Vcc input (on board LDO)
                          pinMode(LTC4067_SUSPEND_PIN, OUTPUT);					// suspend of Lion charger set
                          digitalWrite(LTC4067_SUSPEND_PIN,LOW);   			//  active (non suspend) at start
                        
                        }
                         
                        void loop()     
                        {     
                        
                          sendVoltage();
                          
                            
                          // Power down the radio
                         delay(SLEEP_TIME);
                        }
                        
                        void sendVoltage(void)
                        // battery and charging values
                        {
                        	// get Battery Voltage & charge current
                        	float batteryVoltage = ((float)analogRead(batteryVoltage_PIN)* VccReference/1024) * 2;	// actual voltage is double
                        	Serial.print("Batt: ");
                        	Serial.print(batteryVoltage);
                        	Serial.print("V ; ");
                        	float batteryChargeCurrent = ((float)analogRead(batteryChargeCurrent_PIN) * VccReference/1024)/ 2.5 ; // current(A) = V/Rprog(kohm)
                        	Serial.print(batteryChargeCurrent);
                        	Serial.println("A ");
                        
                           
                        	// get Solar Voltage & charge current
                        	float solarVoltage = ((float)analogRead(solarVoltage_PIN)/1024 * VccReference) * 2 ;		// actual voltage is double
                        	Serial.print("Solar: ");
                        	Serial.print(solarVoltage);
                        	Serial.print("V ; ");
                        	// get Solar Current
                        	float solarCurrent = ((float)analogRead(solarCurrent_PIN)/1024 * VccReference)/ 2.5;		// current(A) = V/Rclprog(kohm)
                        	Serial.print(solarCurrent);
                        	Serial.print(" A; charge: ");
                        	Serial.println(digitalRead(LTC4067_CHRG_PIN)?"No":"Yes");
                        	
                        	// send battery percentage for node
                        	int battPct = 1 ;
                        	if (batteryVoltage > VccMin){
                        		battPct = 100.0*(batteryVoltage - VccMin)/(VccMax - VccMin);
                        	}
                        	Serial.print("BattPct: ");
                        	Serial.print(battPct);
                        	Serial.println("% ");
                        
                        	
                        }
                        

                        z-wave - Vera -&gt; Domoticz
                        rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                        mysensors -&gt; mysensors-gw -&gt; Domoticz

                        AWIA 1 Reply Last reply
                        0
                        • epierreE Offline
                          epierreE Offline
                          epierre
                          Hero Member
                          wrote on last edited by
                          #29

                          I've received a string of 10 radio chipset tonight and changing the component has no effect compared to the other board where radio is ok.

                          are you sure the problem is softare for what I see here is not dependant of a sophisticated library ?

                          I've learned recently of IAQ (incomming assurance quality) because Photon (formerly Sark) has been hit by a suppliers problem: https://community.particle.io/t/photon-manufacturing-shipping-update/12275

                          z-wave - Vera -&gt; Domoticz
                          rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                          mysensors -&gt; mysensors-gw -&gt; Domoticz

                          1 Reply Last reply
                          0
                          • epierreE epierre

                            so the same without sensor nor mysensors... 30 secs fine 40 secs dead...

                            I've removed the radio chipset, same behavior...

                            /*
                             
                            #include <SPI.h>
                            
                            #include <Wire.h> 				// I2C
                            
                            
                            #define LTC4067_CHRG_PIN	A1		//analog input A1 on ATmega 328 is /CHRG signal from LTC4067
                            #define batteryVoltage_PIN	A0		//analog input A0 on ATmega328 is battery voltage ( /2)
                            #define solarVoltage_PIN	A2		//analog input A2 is solar cell voltage (/ 2)
                            #define solarCurrent_PIN	A6		//analog input A6 is input current ( I=V/Rclprog x 1000 )
                            #define batteryChargeCurrent_PIN	A7	//analog input A7 is battery charge current ( I=V/Rprog x 1000 )
                            #define LTC4067_SUSPEND_PIN	9		//digital output D9 - drive it high to put LTC4067 in SUSPEND mode
                            
                            const float VccMin        = 1.0*3.5;  // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion.
                            const float VccMax        = 1.0*4.2;  // Maximum expected Vcc level, in Volts. 
                            
                            #define LIGHT_SENSOR_ANALOG_PIN 3   // Digital input did you attach your soil sensor.  
                            #define CHILD_ID_LIGHT 0   // Id of the sensor child
                            #define BATT_CHILD_ID 10
                            #define SOLAR_CHILD_ID 11
                            
                            // PIN Radio
                            #define RADIO_CE_PIN    7       // radio chip enable
                            #define RADIO_SS_PIN    8      // CS SS serial select
                            
                            float lastBattVoltage;
                            float lastBattCurrent;
                            float lastSolarVoltage;
                            float lastSolarCurrent;
                            int lastBattPct = 0;
                            uint16_t lastlux;
                            float VccReference = 3.3 ;				// voltage reference for measurement, definitive init in setup
                            
                            
                            unsigned long SLEEP_TIME = 40*1000;  // sleep time between reads (seconds * 1000 milliseconds)
                            
                            int lastSoilValue = -1;
                            
                            void setup()  
                            { 
                             
                              Serial.begin(115200);
                              // use VCC (3.3V) reference
                              analogReference(DEFAULT);								// default external reference = 3.3v for Ceech board
                              VccReference = 3.323 ;									// measured Vcc input (on board LDO)
                              pinMode(LTC4067_SUSPEND_PIN, OUTPUT);					// suspend of Lion charger set
                              digitalWrite(LTC4067_SUSPEND_PIN,LOW);   			//  active (non suspend) at start
                            
                            }
                             
                            void loop()     
                            {     
                            
                              sendVoltage();
                              
                                
                              // Power down the radio
                             delay(SLEEP_TIME);
                            }
                            
                            void sendVoltage(void)
                            // battery and charging values
                            {
                            	// get Battery Voltage & charge current
                            	float batteryVoltage = ((float)analogRead(batteryVoltage_PIN)* VccReference/1024) * 2;	// actual voltage is double
                            	Serial.print("Batt: ");
                            	Serial.print(batteryVoltage);
                            	Serial.print("V ; ");
                            	float batteryChargeCurrent = ((float)analogRead(batteryChargeCurrent_PIN) * VccReference/1024)/ 2.5 ; // current(A) = V/Rprog(kohm)
                            	Serial.print(batteryChargeCurrent);
                            	Serial.println("A ");
                            
                               
                            	// get Solar Voltage & charge current
                            	float solarVoltage = ((float)analogRead(solarVoltage_PIN)/1024 * VccReference) * 2 ;		// actual voltage is double
                            	Serial.print("Solar: ");
                            	Serial.print(solarVoltage);
                            	Serial.print("V ; ");
                            	// get Solar Current
                            	float solarCurrent = ((float)analogRead(solarCurrent_PIN)/1024 * VccReference)/ 2.5;		// current(A) = V/Rclprog(kohm)
                            	Serial.print(solarCurrent);
                            	Serial.print(" A; charge: ");
                            	Serial.println(digitalRead(LTC4067_CHRG_PIN)?"No":"Yes");
                            	
                            	// send battery percentage for node
                            	int battPct = 1 ;
                            	if (batteryVoltage > VccMin){
                            		battPct = 100.0*(batteryVoltage - VccMin)/(VccMax - VccMin);
                            	}
                            	Serial.print("BattPct: ");
                            	Serial.print(battPct);
                            	Serial.println("% ");
                            
                            	
                            }
                            
                            AWIA Offline
                            AWIA Offline
                            AWI
                            Hero Member
                            wrote on last edited by
                            #30

                            @epierre this sounds really weird. The delay() you used in this sketch does not sleep anything but just takes an active break. Can you measure the supply voltage on vcc to determine what is happening?

                            1 Reply Last reply
                            0
                            • epierreE Offline
                              epierreE Offline
                              epierre
                              Hero Member
                              wrote on last edited by
                              #31

                              voltage was made through the ftdi...

                              I'll check again, but an interresting result, the unit with sending problems works well when used with the amplified nrf24l !!! ??? !!!

                              I've plugged it too with a 4000mAh LiPo battery I just received. I'll try later to play with sleep or delay

                              2015-07-09 15:14:04 15 10 1 0 38 4.128
                              2015-07-09 15:14:04 15 10 1 0 39 0.001298
                              2015-07-09 15:14:05 15 11 1 0 38 4.524
                              2015-07-09 15:14:06 15 11 1 0 39 0.003894
                              2015-07-09 15:14:06 15 255 3 0 0 89
                              

                              z-wave - Vera -&gt; Domoticz
                              rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                              mysensors -&gt; mysensors-gw -&gt; Domoticz

                              AWIA 1 Reply Last reply
                              0
                              • epierreE epierre

                                voltage was made through the ftdi...

                                I'll check again, but an interresting result, the unit with sending problems works well when used with the amplified nrf24l !!! ??? !!!

                                I've plugged it too with a 4000mAh LiPo battery I just received. I'll try later to play with sleep or delay

                                2015-07-09 15:14:04 15 10 1 0 38 4.128
                                2015-07-09 15:14:04 15 10 1 0 39 0.001298
                                2015-07-09 15:14:05 15 11 1 0 38 4.524
                                2015-07-09 15:14:06 15 11 1 0 39 0.003894
                                2015-07-09 15:14:06 15 255 3 0 0 89
                                
                                AWIA Offline
                                AWIA Offline
                                AWI
                                Hero Member
                                wrote on last edited by
                                #32

                                @epierre said:

                                voltage was made through the ftdi...

                                Are you powering or measuring the unit from ftdi? You should only use the on-board power supply.

                                1 Reply Last reply
                                0
                                • epierreE Offline
                                  epierreE Offline
                                  epierre
                                  Hero Member
                                  wrote on last edited by epierre
                                  #33

                                  Hello,

                                  since I have 2 units, I have one on battery/solar panel and the other with issues on radio through ftdi else I couldn't see what it had to display...

                                  I'm off for a week, I'll do further testing after.

                                  Can you reproduce some part of the delay/speel issue ?

                                  z-wave - Vera -&gt; Domoticz
                                  rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                                  mysensors -&gt; mysensors-gw -&gt; Domoticz

                                  1 Reply Last reply
                                  0
                                  • epierreE Offline
                                    epierreE Offline
                                    epierre
                                    Hero Member
                                    wrote on last edited by
                                    #34

                                    @awi @ceech what test should I do about those units:

                                    • delay test: what kind? what to watch ?
                                    • sleep test: what kind? what to watch ?
                                    • radio issue on one of the boards working only with amplified board, not with small one.

                                    The good news it although they pollute the radio by sending infos every 30s, they are still alive alone with the sun one week after.

                                    z-wave - Vera -&gt; Domoticz
                                    rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                                    mysensors -&gt; mysensors-gw -&gt; Domoticz

                                    C 1 Reply Last reply
                                    0
                                    • epierreE epierre

                                      @awi @ceech what test should I do about those units:

                                      • delay test: what kind? what to watch ?
                                      • sleep test: what kind? what to watch ?
                                      • radio issue on one of the boards working only with amplified board, not with small one.

                                      The good news it although they pollute the radio by sending infos every 30s, they are still alive alone with the sun one week after.

                                      C Offline
                                      C Offline
                                      ceech
                                      Hardware Contributor
                                      wrote on last edited by
                                      #35

                                      @epierre Try comparing the two boards side by side. You'll get an idea where the problem is.

                                      1 Reply Last reply
                                      0
                                      • epierreE Offline
                                        epierreE Offline
                                        epierre
                                        Hero Member
                                        wrote on last edited by epierre
                                        #36

                                        @ceech do you mean on SW or HW side ?

                                        HW:

                                        • I cannot plug the standard radio in one, only amplified works with it
                                        • same solar pannel 1W
                                        • different batteries, one is LiPo, the other is LiOn, but same behavior on delay/sleep seen on both
                                        • same lux sensor

                                        SW: they run the same software

                                        any idea ?

                                        z-wave - Vera -&gt; Domoticz
                                        rfx - Domoticz &lt;- MyDomoAtHome &lt;- Imperihome
                                        mysensors -&gt; mysensors-gw -&gt; Domoticz

                                        C 1 Reply Last reply
                                        0
                                        • epierreE epierre

                                          @ceech do you mean on SW or HW side ?

                                          HW:

                                          • I cannot plug the standard radio in one, only amplified works with it
                                          • same solar pannel 1W
                                          • different batteries, one is LiPo, the other is LiOn, but same behavior on delay/sleep seen on both
                                          • same lux sensor

                                          SW: they run the same software

                                          any idea ?

                                          C Offline
                                          C Offline
                                          ceech
                                          Hardware Contributor
                                          wrote on last edited by
                                          #37

                                          @epierre Not enough power for the amplified radio, probably. Try adding bigger capacitor. In the hundreds of uF region.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          12

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular