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.
  • S Offline
    S Offline
    Samuel235
    Hardware Contributor
    wrote on last edited by
    #1

    Good evening,

    I'm in the process of creating a custom PCB for a light switch and temperature sensor on the board to monitor internal temperature inside of the light switch socket to then maybe trigger an auto shutdown at a certain temp (assuming it would be getting close to catching fire, for some unknown reason). I was looking at the ATmega range of chips from atmel, should i be looking at anything else other than the pin count and the flash size that could limit me? I'm trying to go as small as possible to allow me to fit this behind a light switch and therefor i don't want to increase the size of the PCB because of the chip size if i didn't need to do so. I've just done a quick compile of the switch sketch here and its coming to the following:

    Sketch uses 13,356 bytes (5%) of program storage space. Maximum is 253,952 bytes.
    Global variables use 410 bytes (5%) of dynamic memory, leaving 7,782 bytes for local variables. Maximum is 8,192 bytes.
    

    Now, that doesn't include anything for the temperature sensor that i plan on including with the board. But i'm assuming that wont take up much space. So at the moment its looking to come out at around 13.3KB. I'm going to over compensate and say with any temperature reading on that sketch would make it to around the 20KB mark. But please correct me if you know any differently.

    Could anyone just point out what i need to be looking at in terms of specs for the chip itself other than just the memory size, and the amount of pins it has. It must transmit over an RF24l01 module too, hence why I'm looking at the amount of pins.

    Thanks, Sam.

    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
      #2

      go with an atmega328p, as that is the most widely supported mcu for arduino.

      Unless you are very adventurous and go with something like atmel SAMD2x MCU. But we are just getting support into mysensors library for that one.

      S 1 Reply Last reply
      0
      • tbowmoT tbowmo

        go with an atmega328p, as that is the most widely supported mcu for arduino.

        Unless you are very adventurous and go with something like atmel SAMD2x MCU. But we are just getting support into mysensors library for that one.

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

        @tbowmo I'm currently sketching, documenting and pretty much settling on the 328p tbh, from reading the datasheets, looking at nanos that i currently have and the pinouts, they look a pretty nice little chip. I'm just adding a 16MHz crystal to my schematics, the very few caps, the RF module and the switch plate and i think i'm pretty much there for drafting it up. Then I'll move onto the detailed schematics and maybe a board preview and I'll post it up on my 'build log' for people's opinions.

        So just quickly, what do i need for a very basic arduino board? Currently I have:

        • list itemATmega328p

        • list item16MHz crystal

        • list item2 caps for the crystal

        • Some form of serial connection to upload the bootloader and sketches.

        That is all i have for the arduino section itself, then i will add the battery connection, the RF module and the switch plate. Am i missing anything obvious in your opinion?

        Thanks, Sam.

        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
          #4

          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 M 2 Replies 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)

            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
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          17

                                          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