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. Which ATmega do i go with?

Which ATmega do i go with?

Scheduled Pinned Locked Moved Hardware
atmegamicrocontrollerstand alonediy arduino
24 Posts 5 Posters 9.5k Views 1 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.
  • tbowmoT tbowmo

    You don't need the crystal, there is an internal 8mhz RC oscillator available.

    I would recommend to take a look at the sensebender, it's as basic as it can be (just remove sensor / flash / atsha204 if you don't need those)

    S Offline
    S Offline
    Samuel235
    Hardware Contributor
    wrote on last edited by
    #5

    @tbowmo I've been reading that if i use a 8MHz oscillator (added on, or built in) it could potentially through a few things out of sync including the uploading of the sketch. Also, it stated that it would then take the microcontroller twice as long to perform the tasks. As an example they said that if you put the board to sleep for 9ms and had it performing a task for 1ms every 10ms using a 16MHz crystal that is fine, but if you use a 8MHz it would then make the board sleep for 8ms and perform that task for 2ms, so in some instances it would end up in more power draw over a given length of time.

    Also, after thinking about the flash situation, because this is going to be a battery operated node, i would need some flash memory to hold the sketch in between uploading the sketch and powering the device on with the battery, and when i come to change the battery it would lose the sketch if i didn't have any flash. Am i correct in saying this?

    MySensors 2.1.1
    Controller - OpenHAB (Virtual Machine)
    Gateway - Arduino Mega MQTT Gateway W5100

    1 Reply Last reply
    0
    • tbowmoT Offline
      tbowmoT Offline
      tbowmo
      Admin
      wrote on last edited by
      #6

      @samuel235

      Running higher frequency will use more current.. In theory keep your oscillator frequency as low as possible. Also you should have a look at how often you want to report the temperature. Normal temperature sketches are measuring once every minute (or even less frequently). Then it doesn't matter if it takes 1 mili second, or 2 mili seconds to perform an operation.

      Also, what temperature sensor are you planning to use? If it's digital, your MCU is probably going to wait for the temperature conversion etc.. anyways, (which can be up to several mili seconds). So again, it doesn't matter if the MCU is running 8 or 16Mhz.

      Another point, is that for running 16Mhz, you need to supply the atmega328p with 5V, as it's not rated for running 16Mhz at 3V (or lower). That means you need to have a "5V battery" (stepup or the like). in order to get it running at 5V.

      Now for the external flash, and bootloader support. There are two bootloaders available for OTA FW upgrades.

      • MysBootloader - no external flash needed, but only supports NRF24, and no security features (signing etc.)
      • DualOptiboot - needs external flash to store fw while uploading it. Supporting both NRF24 and RFM69 radios, and supports signing (dev branch of Mysensors library is probably needed)

      If you use MysBootloader, it doesn't loose firmware if it looses power. Firmware is still stored in internal flash on the MCU, but the node will not function normally while uploading a new sketch, as it's in bootloader mode. While using DualOptiboot / external flash, node will continue to work with the old sketch, untill the new sketch is uploaded to the node (external flash) and verified, after which the content of the external flash will be moved to internal MCU flash and executed.

      S 2 Replies Last reply
      1
      • tbowmoT tbowmo

        @samuel235

        Running higher frequency will use more current.. In theory keep your oscillator frequency as low as possible. Also you should have a look at how often you want to report the temperature. Normal temperature sketches are measuring once every minute (or even less frequently). Then it doesn't matter if it takes 1 mili second, or 2 mili seconds to perform an operation.

        Also, what temperature sensor are you planning to use? If it's digital, your MCU is probably going to wait for the temperature conversion etc.. anyways, (which can be up to several mili seconds). So again, it doesn't matter if the MCU is running 8 or 16Mhz.

        Another point, is that for running 16Mhz, you need to supply the atmega328p with 5V, as it's not rated for running 16Mhz at 3V (or lower). That means you need to have a "5V battery" (stepup or the like). in order to get it running at 5V.

        Now for the external flash, and bootloader support. There are two bootloaders available for OTA FW upgrades.

        • MysBootloader - no external flash needed, but only supports NRF24, and no security features (signing etc.)
        • DualOptiboot - needs external flash to store fw while uploading it. Supporting both NRF24 and RFM69 radios, and supports signing (dev branch of Mysensors library is probably needed)

        If you use MysBootloader, it doesn't loose firmware if it looses power. Firmware is still stored in internal flash on the MCU, but the node will not function normally while uploading a new sketch, as it's in bootloader mode. While using DualOptiboot / external flash, node will continue to work with the old sketch, untill the new sketch is uploaded to the node (external flash) and verified, after which the content of the external flash will be moved to internal MCU flash and executed.

        S Offline
        S Offline
        Samuel235
        Hardware Contributor
        wrote on last edited by
        #7

        @tbowmo First of all - Thank you for such an in depth answer and explanation, the reason i turn to the forums to ask questions is not because i was swift, short and straight to the point answers, its because i'm actually interested in learning along the way. A true maker enjoys the build as much as the end product ;)

        So, after your advice on the crystal i think i will go ahead and use the on board clock for the 8MHz oscillator. The idea of the Dallas DS18B20 temperature sensor that i was going to have soldered onto the board was simply to monitor the temperature of the this board inside of the switch socket (this whole board will be located behind a wall switch, hence the need for a ultra small custom pcb). I wasn't going to get this information to be sent to the controller, i was hoping to figure out a way to auto switch off the node if it hit a certain temperature, and send a message/alert to the controller before turning off, if possible. However, i'm not considering to send the temp data whenever the switch is used, but that is just an idea (will use the battery a lot quicker than just keeping it internal, so i might not do so). As for the type of the temperature sensor, i'm just assuming i will be using a Dallas DS18B20, but if there is a lower power option out there, i will be sure to use that when i come to ordering the parts.

        I will more than likely be using the MysBootloader as i don't really need any of the options that DualOptiboot offers, i certainly don't need the node to be running the current sketch while i upload a new one, as a switch it wont be used while uploading a new sketch anyway. I have no plans to use this as another node other than a switch either. On the plus side, the MysBootloader will allow me to have a smaller footprint on the PCB too.

        MySensors 2.1.1
        Controller - OpenHAB (Virtual Machine)
        Gateway - Arduino Mega MQTT Gateway W5100

        1 Reply Last reply
        0
        • scalzS Offline
          scalzS Offline
          scalz
          Hardware Contributor
          wrote on last edited by
          #8

          hi.

          Maybe you have already thought about this...but if it is batt powered. I guess you will use sleep mode. and maybe wake up on switch contact..but if it sleeps, you won't be able to receive an order from your controller to toggle your light.

          S 1 Reply Last reply
          0
          • scalzS scalz

            hi.

            Maybe you have already thought about this...but if it is batt powered. I guess you will use sleep mode. and maybe wake up on switch contact..but if it sleeps, you won't be able to receive an order from your controller to toggle your light.

            S Offline
            S Offline
            Samuel235
            Hardware Contributor
            wrote on last edited by
            #9

            @scalz I'm planning on running the bare minimum on this node so it will literally be a switch that sends ON or OFF to the controller to then turn my relay node on or off, this node will not be the actual relay. So in terms of sketches, this will run a version of the 'BinarySwitchSensor', send data to controller which will then send the on of off to my relay node running 'RelayActuator'.

            So this should be fine to be sleeping, until it receives a switch state change. I'm not sure how i would do the temperature cut off if the node was asleep until the switch is used, because i wouldn't be able to say "If the temp hit X°C then send message/alert and turn off" if the node was sleeping.

            MySensors 2.1.1
            Controller - OpenHAB (Virtual Machine)
            Gateway - Arduino Mega MQTT Gateway W5100

            1 Reply Last reply
            0
            • tbowmoT Offline
              tbowmoT Offline
              tbowmo
              Admin
              wrote on last edited by
              #10

              @samuel235

              If this is only a node for sending off a switch command, then why bother with temperature monitoring? It will be sleeping all day, until you press that button on it. And afterwards it will be sleeping again until next time you press it again. the MCU will not be generating any heat, and neither would the radio module (as it will be at sleep for most of the time)

              Also, be aware that the DS1820 doesn't operate below 3V, so that also puts some requirements on your supply voltage.

              S 1 Reply Last reply
              0
              • scalzS Offline
                scalzS Offline
                scalz
                Hardware Contributor
                wrote on last edited by
                #11

                oki I see :wink: I am not at my best this morning lol.
                yep, you are right about your sensors and power consumption. keep thing simple to design your board. you will have time then to improve it ;) so sensebender is a great start for what you want to do..

                on my side I am adapting mytinycamel circuit to make a simple batt powered node inwall. but with a shield for sensors..I will show you when finished. it's much more when you need other sensors..because for a switch node, your project is fine :smiley:

                1 Reply Last reply
                0
                • tbowmoT tbowmo

                  @samuel235

                  If this is only a node for sending off a switch command, then why bother with temperature monitoring? It will be sleeping all day, until you press that button on it. And afterwards it will be sleeping again until next time you press it again. the MCU will not be generating any heat, and neither would the radio module (as it will be at sleep for most of the time)

                  Also, be aware that the DS1820 doesn't operate below 3V, so that also puts some requirements on your supply voltage.

                  S Offline
                  S Offline
                  Samuel235
                  Hardware Contributor
                  wrote on last edited by
                  #12

                  @tbowmo - I was only having the temp sensor there in case of a irrational/unpredicted sense of events and causes a fire, hoping my theory would make this board over the top safe. However if you feel that there would be no chance what so ever of this happening i will not bother using it.

                  On the chip front, would i be better using something smaller/less power hungry since i'm only using a switch and the radio here? I'll stick with the 328-PU if there isn't much power i can reduce it by.

                  @scalz - Indeed, like i have said before, i love the look of your 'MyTinyCamel' board. I also love the idea of your sensor board in the wall too, this will be my next application, however I wanted to design this for the cases where you are very limited on space inside of your wall socket and just needed a switch node. I can only hope to develop our products together at some point in the future ;)

                  MySensors 2.1.1
                  Controller - OpenHAB (Virtual Machine)
                  Gateway - Arduino Mega MQTT Gateway W5100

                  1 Reply Last reply
                  0
                  • scalzS Offline
                    scalzS Offline
                    scalz
                    Hardware Contributor
                    wrote on last edited by scalz
                    #13

                    :sunglasses:
                    for the chip, I agree with tbowmo. you should use 328p I think. p for picopower (140-200nA max sleeping, on standalone), widely arduino and mysensors used. enough mem to handle mysensors lib, radio..no big surprise.

                    1 Reply Last reply
                    0
                    • tbowmoT Offline
                      tbowmoT Offline
                      tbowmo
                      Admin
                      wrote on last edited by
                      #14

                      @samuel235

                      Go with 328p.. you'll only get more problems, if you choose other chips (like the attiny mcus)

                      328 is the standard for arduino. Just be sure that you have access to programming (ISP port) pins on the mcu, otherwise you'll have problems in putting in the bootloader.

                      1 Reply Last reply
                      0
                      • tbowmoT tbowmo

                        You don't need the crystal, there is an internal 8mhz RC oscillator available.

                        I would recommend to take a look at the sensebender, it's as basic as it can be (just remove sensor / flash / atsha204 if you don't need those)

                        M Offline
                        M Offline
                        Mickey
                        wrote on last edited by
                        #15

                        @tbowmo said:

                        You don't need the crystal, there is an internal 8mhz RC oscillator available.

                        I would recommend to take a look at the sensebender, it's as basic as it can be (just remove sensor / flash / atsha204 if you don't need those)

                        How do you programme a factory atmega328p to run on 8mhz internal?

                        S 1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Samuel235
                          Hardware Contributor
                          wrote on last edited by
                          #16

                          Right, okay. So 328-PU it is. By the way just to let you know i was looking at the likes of the ATmega8, and others in the mega range. Wasn't bothering with the ATtiny range. But i'll stick with ATmega328-PU. But other than the chip, rf24, the switch and a serial connection for uploading the bootloader and sketch, i don't need anything else to have a functioning 'arduino', right?

                          Ill get some more design and schematic work done when i get home from work tonight and get some drafts up on here.

                          MySensors 2.1.1
                          Controller - OpenHAB (Virtual Machine)
                          Gateway - Arduino Mega MQTT Gateway W5100

                          1 Reply Last reply
                          0
                          • M Mickey

                            @tbowmo said:

                            You don't need the crystal, there is an internal 8mhz RC oscillator available.

                            I would recommend to take a look at the sensebender, it's as basic as it can be (just remove sensor / flash / atsha204 if you don't need those)

                            How do you programme a factory atmega328p to run on 8mhz internal?

                            S Offline
                            S Offline
                            Samuel235
                            Hardware Contributor
                            wrote on last edited by
                            #17

                            @Mickey said:

                            @tbowmo said:

                            You don't need the crystal, there is an internal 8mhz RC oscillator available.

                            I would recommend to take a look at the sensebender, it's as basic as it can be (just remove sensor / flash / atsha204 if you don't need those)

                            How do you programme a factory atmega328p to run on 8mhz internal?

                            I have the line of code in my documents at home somewhere, ill post them later if no body provides anything by then. If i can find them that is.

                            MySensors 2.1.1
                            Controller - OpenHAB (Virtual Machine)
                            Gateway - Arduino Mega MQTT Gateway W5100

                            1 Reply Last reply
                            0
                            • tbowmoT Offline
                              tbowmoT Offline
                              tbowmo
                              Admin
                              wrote on last edited by tbowmo
                              #18

                              @Mickey

                              By default the atmega328p is running from the internal 8Mhz oscillator, but with clkdiv8 enabled, so that it runs at 1Mhz. For running it at 8Mhz you have to set the fuses and disable the clkdiv8. I'm using the following avrdude command to set fuses with my jtagice3 programmer in an atmega328p

                              avrdude -c jtag3isp -p m328p\
                              -U lfuse:w:0xE2:m \
                              -U hfuse:w:0xD2:m \
                              -U efuse:w:0xFE:m \
                              -U lock:w:0xEF:m 
                              

                              change above to use the programmer that you have

                              M 1 Reply Last reply
                              0
                              • tbowmoT tbowmo

                                @Mickey

                                By default the atmega328p is running from the internal 8Mhz oscillator, but with clkdiv8 enabled, so that it runs at 1Mhz. For running it at 8Mhz you have to set the fuses and disable the clkdiv8. I'm using the following avrdude command to set fuses with my jtagice3 programmer in an atmega328p

                                avrdude -c jtag3isp -p m328p\
                                -U lfuse:w:0xE2:m \
                                -U hfuse:w:0xD2:m \
                                -U efuse:w:0xFE:m \
                                -U lock:w:0xEF:m 
                                

                                change above to use the programmer that you have

                                M Offline
                                M Offline
                                Mickey
                                wrote on last edited by Mickey
                                #19

                                @tbowmo said:

                                @Mickey

                                By default the atmega328p is running from the internal 8Mhz oscillator, but with clkdiv8 enabled, so that it runs at 1Mhz. For running it at 8Mhz you have to set the fuses and disable the clkdiv8. I'm using the following avrdude command to set fuses with my jtagice3 programmer in an atmega328p

                                avrdude -c jtag3isp -p m328p\
                                -U lfuse:w:0xE2:m \
                                -U hfuse:w:0xD2:m \
                                -U efuse:w:0xFE:m \
                                -U lock:w:0xEF:m 
                                

                                change above to use the programmer that you have

                                So if my current fuses are like this:
                                virginfuses.png
                                can I still communicate with the chip with usbasp without external crystal?

                                1 Reply Last reply
                                0
                                • tbowmoT tbowmo

                                  @samuel235

                                  Running higher frequency will use more current.. In theory keep your oscillator frequency as low as possible. Also you should have a look at how often you want to report the temperature. Normal temperature sketches are measuring once every minute (or even less frequently). Then it doesn't matter if it takes 1 mili second, or 2 mili seconds to perform an operation.

                                  Also, what temperature sensor are you planning to use? If it's digital, your MCU is probably going to wait for the temperature conversion etc.. anyways, (which can be up to several mili seconds). So again, it doesn't matter if the MCU is running 8 or 16Mhz.

                                  Another point, is that for running 16Mhz, you need to supply the atmega328p with 5V, as it's not rated for running 16Mhz at 3V (or lower). That means you need to have a "5V battery" (stepup or the like). in order to get it running at 5V.

                                  Now for the external flash, and bootloader support. There are two bootloaders available for OTA FW upgrades.

                                  • MysBootloader - no external flash needed, but only supports NRF24, and no security features (signing etc.)
                                  • DualOptiboot - needs external flash to store fw while uploading it. Supporting both NRF24 and RFM69 radios, and supports signing (dev branch of Mysensors library is probably needed)

                                  If you use MysBootloader, it doesn't loose firmware if it looses power. Firmware is still stored in internal flash on the MCU, but the node will not function normally while uploading a new sketch, as it's in bootloader mode. While using DualOptiboot / external flash, node will continue to work with the old sketch, untill the new sketch is uploaded to the node (external flash) and verified, after which the content of the external flash will be moved to internal MCU flash and executed.

                                  S Offline
                                  S Offline
                                  Samuel235
                                  Hardware Contributor
                                  wrote on last edited by Samuel235
                                  #20

                                  @tbowmo said:

                                  Now for the external flash, and bootloader support. There are two bootloaders available for OTA FW upgrades.

                                  • MysBootloader - no external flash needed, but only supports NRF24, and no security features (signing etc.)
                                  • DualOptiboot - needs external flash to store fw while uploading it. Supporting both NRF24 and RFM69 radios, and supports signing (dev branch of Mysensors library is probably needed)

                                  Without using external flash could i use the Arduino bootloader? Did you only mention these 2 for their "OTA Firmware upgrade" ability? I'm struggling to workout how to burn this MysBootloader onto my chip. I can't find much information on this.

                                  EDIT: So, I've been reading on the Google Docs for bootloading, and it would appear all that i have to do is put the MysBootloader sub-folder into the bootloaders folder in my Arduino IDE documents. So, i have done that but i still only have "Burn Bootloader" in the tools drop down menu, is this normal not to be able to choose which bootloader i would like to burn or do i need to have my board plugged into my computer to then be recognised to be able to burn MYSBootloader?

                                  MySensors 2.1.1
                                  Controller - OpenHAB (Virtual Machine)
                                  Gateway - Arduino Mega MQTT Gateway W5100

                                  tekkaT 1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    Samuel235
                                    Hardware Contributor
                                    wrote on last edited by
                                    #21

                                    And which way is your/the preferred method of burning the bootloader, would you use a Arduino Uno and burn the bootloader using the "Arduino as ISP" option or would you go with something like a USBtinyISP adapter? Could you provide a link for a specific programmer if you use one as I'm seeing a lot of varying types/sizes/shapes and I'de like a recommendation of a working device from someone that uses one. If you use an Arduino UNO, i will just purchase one of those instead.

                                    MySensors 2.1.1
                                    Controller - OpenHAB (Virtual Machine)
                                    Gateway - Arduino Mega MQTT Gateway W5100

                                    1 Reply Last reply
                                    0
                                    • S Samuel235

                                      @tbowmo said:

                                      Now for the external flash, and bootloader support. There are two bootloaders available for OTA FW upgrades.

                                      • MysBootloader - no external flash needed, but only supports NRF24, and no security features (signing etc.)
                                      • DualOptiboot - needs external flash to store fw while uploading it. Supporting both NRF24 and RFM69 radios, and supports signing (dev branch of Mysensors library is probably needed)

                                      Without using external flash could i use the Arduino bootloader? Did you only mention these 2 for their "OTA Firmware upgrade" ability? I'm struggling to workout how to burn this MysBootloader onto my chip. I can't find much information on this.

                                      EDIT: So, I've been reading on the Google Docs for bootloading, and it would appear all that i have to do is put the MysBootloader sub-folder into the bootloaders folder in my Arduino IDE documents. So, i have done that but i still only have "Burn Bootloader" in the tools drop down menu, is this normal not to be able to choose which bootloader i would like to burn or do i need to have my board plugged into my computer to then be recognised to be able to burn MYSBootloader?

                                      tekkaT Offline
                                      tekkaT Offline
                                      tekka
                                      Admin
                                      wrote on last edited by tekka
                                      #22

                                      @samuel235 Please follow these instructions for burning MYSBootloader and testing OTA updates with MYSController. Both, USBasp and ArudinoISP are easy to use as long as you do not mix up the cables...

                                      S 1 Reply Last reply
                                      1
                                      • tekkaT tekka

                                        @samuel235 Please follow these instructions for burning MYSBootloader and testing OTA updates with MYSController. Both, USBasp and ArudinoISP are easy to use as long as you do not mix up the cables...

                                        S Offline
                                        S Offline
                                        Samuel235
                                        Hardware Contributor
                                        wrote on last edited by
                                        #23

                                        @tekka - How on earth did i not stumble across this! Thank you very much! I will get ordering myself an UNO in preperation to getting my board manufactured. Now i know which connections are needed in my ISP header, i will carry on sketching out the schematic. Thank you once again!

                                        MySensors 2.1.1
                                        Controller - OpenHAB (Virtual Machine)
                                        Gateway - Arduino Mega MQTT Gateway W5100

                                        1 Reply Last reply
                                        0
                                        • tbowmoT Offline
                                          tbowmoT Offline
                                          tbowmo
                                          Admin
                                          wrote on last edited by
                                          #24

                                          @samuel235

                                          I'm using genuine atmel programmers (currently I'm on jtagice3) been serving me fine for the last couple of years (also have the added benefits of being able to work together with gdb, so I can debug arduino code on my atmel sam D21 mcu)

                                          Anyways, there are lot's of (cheaper) programmers out there, amongst others you could use another arduino as programmer..

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


                                          11

                                          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