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. My Project
  3. A tiny BME node - BME280 on ATtiny85

A tiny BME node - BME280 on ATtiny85

Scheduled Pinned Locked Moved My Project
28 Posts 8 Posters 493 Views 12 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.
  • chamroeun ouC Offline
    chamroeun ouC Offline
    chamroeun ou
    wrote on last edited by
    #21

    Ok, now it works with your BME-i2c code. not enough memory maybe due to update in AttinyCore which is bigger than your version. I think memory limit is the challenge.

    1 Reply Last reply
    0
    • chamroeun ouC Offline
      chamroeun ouC Offline
      chamroeun ou
      wrote on last edited by
      #22

      To use Attiny, i think there's a need to optimize Mysensor for it as Mysensor consumes the most space of the 8K.

      BearWithBeardB 1 Reply Last reply
      0
      • chamroeun ouC chamroeun ou

        To use Attiny, i think there's a need to optimize Mysensor for it as Mysensor consumes the most space of the 8K.

        BearWithBeardB Offline
        BearWithBeardB Offline
        BearWithBeard
        wrote on last edited by BearWithBeard
        #23

        @chamroeun-ou I think it's actually quite fascinating that you can fit MySensors in less than 5kb of memory! Consider all the things the library does behind the scenes and that this includes all the required dependencies.

        Try using your BME280 on the SPI bus, which you need anyway for the transceiver. This should shave off about 800 bytes or so. It still fits on ATtinys with 8kb flash using the example sketch posted above (direct link).

        Processing attiny85 (platform: atmelavr; board: attiny85; framework: arduino)
        -------------------------------------------------------------------------------------
        PLATFORM: Atmel AVR (3.3.0) > Generic ATtiny85
        HARDWARE: ATTINY85 8MHz, 512B RAM, 8KB Flash
        PACKAGES:
         - framework-arduino-avr-attiny 1.5.2
         - toolchain-atmelavr 1.70300.191015 (7.3.0)
        RAM:   [=======   ]  65.8% (used 337 bytes from 512 bytes)
        Flash: [==========]  97.2% (used 7960 bytes from 8192 bytes)
        
        1 Reply Last reply
        1
        • chamroeun ouC Offline
          chamroeun ouC Offline
          chamroeun ou
          wrote on last edited by
          #24

          @BearWithBeard , it's not my code. it is based on @fabyte 's code. Actually, I want to use SHT30 I2C but space is the biggest challenge.

          There's a NRFLite(https://github.com/dparson55/NRFLite) which I think it may save space and can also work with 2 PIN for NRF24 as its created for Attiny but it may not work MySensors without code change.

          My decision now is to use Attiny167 instead but the problem now is it's not working on Mysensors. I try this approach but not work https://github.com/mysensors/MySensors/pull/1485.

          BearWithBeardB 1 Reply Last reply
          0
          • chamroeun ouC chamroeun ou

            @BearWithBeard , it's not my code. it is based on @fabyte 's code. Actually, I want to use SHT30 I2C but space is the biggest challenge.

            There's a NRFLite(https://github.com/dparson55/NRFLite) which I think it may save space and can also work with 2 PIN for NRF24 as its created for Attiny but it may not work MySensors without code change.

            My decision now is to use Attiny167 instead but the problem now is it's not working on Mysensors. I try this approach but not work https://github.com/mysensors/MySensors/pull/1485.

            BearWithBeardB Offline
            BearWithBeardB Offline
            BearWithBeard
            wrote on last edited by
            #25

            @chamroeun-ou I'm sorry, I was under the impression that you want to rebuild the OP's project, since there was no mention of different sensors etc.

            Regarding the ATtiny85: How would you have used both SPI and I2C together in the first place? Both are implemented through a single USI and have to share the same OI pins.

            Regarding the ATtiny167: I don't think I have an ATtiny167 at hand currently, so I can't test if it'll actually work, but the OP's example code compiled fine for me. I just had to comment out the the external interrupt flag register redefinition (//#define EIFR GIFR), since it is implemented in the same way it is on the ATmega328P for example.

            Processing attiny167 (platform: atmelavr; board: attiny167; framework: arduino)
            -------------------------------------------------------------------------------
            PLATFORM: Atmel AVR (3.3.0) > Generic ATtiny167
            HARDWARE: ATTINY167 8MHz, 512B RAM, 16KB Flash
            PACKAGES:
             - framework-arduino-avr-attiny 1.5.2
             - toolchain-atmelavr 1.70300.191015 (7.3.0)
            RAM:   [=======   ]  65.0% (used 333 bytes from 512 bytes)
            Flash: [=====     ]  50.5% (used 8274 bytes from 16384 bytes)
            

            The ATtiny167 has dedicated SPI and I2C interfaces and IO pins, so it should be possible to use it as a MySensors node with an SHTC30 sensor. There's plenty of free space, too.

            1 Reply Last reply
            0
            • chamroeun ouC Offline
              chamroeun ouC Offline
              chamroeun ou
              wrote on last edited by
              #26

              @BearWithBeard How do you get it compiled using Mysensors? which code you based on? I got many compiled errors:

              In function 'void hwPowerDown(uint8_t)':
              ../MySensors/hal/architecture/AVR/MyHwAVR.cpp:93:26: error: 'WDTCSR' was not declared in this scope
              const uint8_t WDTsave = WDTCSR;
              ^~~~~~
              
              /../MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'uint16_t hwCPUFrequency()':
              /../MySensors/hal/architecture/AVR/MyHwAVR.cpp:305:26: error: 'WDTCSR' was not declared in this scope
              const uint8_t WDTsave = WDTCSR;
              ^~~~~~
              ..MySensors/hal/architecture/AVR/MyMainAVR.cpp: In function 'int main()':
              Arduino/libraries/MySensors/hal/architecture/AVR/MyMainAVR.cpp:34:7: error: 'serialEventRun' was not declared in this scope
              if (serialEventRun) {`
              

              For your question on SPI+IIC on Attiny85, someone has done it successfully by using NRF24 3 PIN so it's left with 2 PIN and use SoftWire library to force BME t use those two PINs.

              Another sketch that I come across is like this: https://github.com/chaeplin/esp8266_and_arduino/tree/master/_51-attiny85-nrf24-lcd-getntp
              But I can't get it to work maybe due to some pullup resistor or something.

              BearWithBeardB 1 Reply Last reply
              0
              • chamroeun ouC chamroeun ou

                @BearWithBeard How do you get it compiled using Mysensors? which code you based on? I got many compiled errors:

                In function 'void hwPowerDown(uint8_t)':
                ../MySensors/hal/architecture/AVR/MyHwAVR.cpp:93:26: error: 'WDTCSR' was not declared in this scope
                const uint8_t WDTsave = WDTCSR;
                ^~~~~~
                
                /../MySensors/hal/architecture/AVR/MyHwAVR.cpp: In function 'uint16_t hwCPUFrequency()':
                /../MySensors/hal/architecture/AVR/MyHwAVR.cpp:305:26: error: 'WDTCSR' was not declared in this scope
                const uint8_t WDTsave = WDTCSR;
                ^~~~~~
                ..MySensors/hal/architecture/AVR/MyMainAVR.cpp: In function 'int main()':
                Arduino/libraries/MySensors/hal/architecture/AVR/MyMainAVR.cpp:34:7: error: 'serialEventRun' was not declared in this scope
                if (serialEventRun) {`
                

                For your question on SPI+IIC on Attiny85, someone has done it successfully by using NRF24 3 PIN so it's left with 2 PIN and use SoftWire library to force BME t use those two PINs.

                Another sketch that I come across is like this: https://github.com/chaeplin/esp8266_and_arduino/tree/master/_51-attiny85-nrf24-lcd-getntp
                But I can't get it to work maybe due to some pullup resistor or something.

                BearWithBeardB Offline
                BearWithBeardB Offline
                BearWithBeard
                wrote on last edited by
                #27

                @chamroeun-ou I used the example sketch from the OP further up in this thread (direct link). The relevant defines are also mentioned in the software section of the first post.

                You need to add the following to your sketch to get rid of the compiler errors:

                #define WDTCSR  WDTCR   // WDT Control Register
                extern void serialEventRun(void) __attribute__((weak));
                

                Note that ATtinys aren't officially supported by MySensors. Although they may work fine in many instances, you are basically on your own if you run into issues. There simply aren't many people who use MySensors on ATtinys.

                You're much more likely to find help if you use a more common MCU, like the ATmega328P. You'll find a list of MySensors-supported architectures on the Overview page.

                1 Reply Last reply
                1
                • chamroeun ouC Offline
                  chamroeun ouC Offline
                  chamroeun ou
                  wrote on last edited by
                  #28

                  @BearWithBeard said in A tiny BME node - BME280 on ATtiny85:

                  Overview page

                  @BearWithBeard thanks, now i got my Attiny167+Sht30 working with Mysensors and Mysensor gateway. Next step will be formatting the data for Thingsboard cloud.

                  1 Reply Last reply
                  1
                  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.0k

                  Posts


                  Copyright 2019 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