Bootloader for 168V 8Mhz 1.9v bod anyone?



  • Does anyone know where I might find bootloaders for 168v? I have a few prominis with this chip and plan to use them as battery nodes for door/window. Any help gratefully received!



  • @skywatch Huh! I didn't know there was a ATmega168 with a V and had to look it up.

    Maybe I'm wrong, but comparing datasheets of both 168-variants and looking at some of the older Arduinos, I guess you could use a regular ATmega168 bootloader without any suffix. The Arduino folks seem to have done that with the 168V-based Lillypad for example.

    MiniCore for example provides a bootloader for a 1MHz 168 and the fuse settings (for BOD) seem to match as well.

    You may have a look at that unless you found a suitable 168V bootloader in the meantime.

    Edit: replaced all 186 with 168. 😊



  • @BearWithBeard said in Bootloader for 168V 8Mhz 1.9v bod anyone?:

    @skywatch Huh! I didn't know there was a ATmega186 with a V and had to look it up.

    I didn't know they made a 186! πŸ˜‰

    Joking aside, thank you very much for taking some time to help me out here. It is kind of you to do that! - I just downloaded minicore (which I looked at a week ago but never really got that far with it as had other issues to fix first).

    As luck would have it I only found 1 of the 10x 168 boards and can't find the others anywhere! - But I can ecperiment with the one I have and when the rest of them turn up I can move things quickly. They were an unintentional purchase but with goods from Aliexpress now 20% more expensive for us in UK, I have to make do with what I have!

    Next few days I hope to play with it some more and I'll be sure to let you know how I get on! πŸ™‚



  • @skywatch OK - so I burned the 2MHz minicore bootloader (9600 baud) and then a sleeping sketch. Removed the regulator and series resistor for the led. Connected power with no radio connected and I am getting 1.78mA drawn at 3.00V in sleep mode.

    Methinks something not quite right here, will try another module soon.



  • A thought occured to me last night that without a radio connected the node may not be going to sleep - A test today with debug confirmed that, so I soldered a NRF24 to the pro mini. Wow! - what an improvement. Now in sleep mode it is using just 24.4uA - I am very pleased with this and just need to test it down to 1.8V, test the contact sensing is working OK and then I am done with the door/window sensors (apart from actually building and installing them!).

    I have chosen reed relays with NO and NC contacts. This means that contact for the pull down will only happen when the door is open. This should reduce the quiescent current through the pullup resistor when the door is shut. I just need to reverse the trigger logic which is trivial. It might be a small difference, but it all helps! πŸ˜‰

    Thanks again to @BearWithBeard for the hint about minicore. It's easy for beginners and perhaps should get a mention in the bootloaders section.



  • AFter more testing it just got better. It seems that the atmel 168 has enough memory (just) for mysensors running nrf24, 2x interrupts and a HTU21D temp and humidity sensor. I tested overnight and it is working as expected. I didn't think the chip was as capable as it appears to be!

    Also good is that I have tested it working down to 1.64V. This works even sending the temp and hum values, but at 1.63V it no longer transmits anything.

    Looking at the standard mysensors battery page it seems that the battery percentage is sent using 0V as 0% and Vcc as 100%. In practice the battery levels will be unlikely to go below 50% giving a false reading of how much drop in voltage has actually occured.

    To make it more accurate I have set brown out voltage as 0% and Vcc as 100% giving the full range to the expected battery life which is a more accurate reflection of battery usage and time left.

    Here is the code I used to do it...Only the bits added for this to work, include in your own sketch if you want.

    
    int oldBatteryPcnt = 0;
    int batteryPcnt = 0;
    long result = 0;
    float vSend = 0.;
    
    float BattMax = 3.00;             //  Maximum battery voltage (take reading before using or use battery rated value...)
    float brown_out_voltage = 1.7;    //lowest battery voltage equating to 0% battery power (ie battery empty). 
    float brown_out = 0.;
    float divisor = 0.;
    
    void setup()
    {
      divisor = BattMax / 1024;                    //Set batt 100% - here it is 3V/1024
      brown_out = brown_out_voltage / divisor;     //Set batt 0% to brown out voltage
     }
    
    
    void loop()
    {
      
        readVcc();  //only if using internal method, if not replace with external value.
    
       
        vSend = float((result) / 1000.0);
    
        //calc and send batt percent to controller...
        float sensorValue = vSend / divisor;                                          //Get voltage %
        int sensorVal = constrain(sensorValue, brown_out, 1023);        //constrain values.
        batteryPcnt = map (sensorVal, brown_out, 1023, 0, 100);         //Integer pcnt value.
    
        if (oldBatteryPcnt != batteryPcnt) {
          sendBatteryLevel(batteryPcnt);
          oldBatteryPcnt = batteryPcnt;
        }
    }
    

    Now you have percentage between brown out voltage (either measured with volt meter or using the fuse value set on node) as 0% and Vcc (either measured with a volt meter or set for the battery type/combination) as 100% at new.


Log in to reply
 

Suggested Topics

  • 4
  • 2
  • 9
  • 20
  • 9
  • 17

10
Online

11.4k
Users

11.1k
Topics

112.7k
Posts