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. Enclosures / 3D Printing
  3. MySensors weather station

MySensors weather station

Scheduled Pinned Locked Moved Enclosures / 3D Printing
138 Posts 16 Posters 58.7k Views 15 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.
  • YveauxY Yveaux

    @dbemowsk Let's break that line down, using the ATmega328P datasheet (pg. 221,222):

    SPCR = (1<<SPE) | (1<<MSTR) | (1<<CPHA) | (1<<SPR1) | (1<<SPR0)
    
    • SPCR : SPI Control Register 0
    • Bits not explicitly stated are 0, and can be read as (0<<xxx)
    • (1<<SPE) : Enable SPI
    • (0<<DORD) : Data order; here 0 to indicate MSB first
    • (1<<MSTR) : Master/slave select; here 1 to indicate master
    • (0<<CPOL): Clock polarity; here 0 to indicate SCK is low when idle
    • (1<<CPHA) : Clock phase; here 1 to indicate sample on trailing edge
    • (1<<SPR1) | (1<<SPR0) : Clock rate select; here 011 indicating Fosc/128

    The SPISettings is used as follows:

    SPISettings(clockrate, order, mode)
    
    • Let's start with the easy one: clockrate.
      The driver above uses Fosc/128, which is 16000000/128=125000 for a 16MHz crystal. This seems a safe value as the AS5047 datasheet states tclk=100ns, so it can handle 10MHz.
    • Order is just the DORD parameter, so MSBFIRST.
    • Then the tricky one: SPI_MODE
      Here's an extensive explanation. It's a combination of clock phase and clock polarity. Luckily the datasheet states explicitly: "The AS5047D SPI uses mode=1 (CPOL=0, CPHA=1) to exchange data.", so use SPI_MODE1

    Putting things together and wrapping SPI communication with transactions the result should be be:

    uint32_t AS5047::read_register(uint32_t thisRegister)
    {
        ....
        SPI.beginTransaction( SPISettings(125000, MSBFIRST, SPI_MODE1) );
        ....
        digitalWrite(_ss, LOW);
        SPI.transfer(highbyte); // first byte in
        ....
        digitalWrite(_ss, HIGH);
        SPI.endTransaction()
        ....
    }
    

    The clockrate can be increased if you like.

    dbemowskD Offline
    dbemowskD Offline
    dbemowsk
    wrote on last edited by
    #129

    @Yveaux I cannot thank you enough. I tried these transaction settings and this worked perfectly. My hat is off to you.

    Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
    Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

    YveauxY 1 Reply Last reply
    0
    • dbemowskD dbemowsk

      @Yveaux I cannot thank you enough. I tried these transaction settings and this worked perfectly. My hat is off to you.

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #130

      @dbemowsk great to hear!
      I hope I managed to explain to you how to get to these values, as you wanted to learn from the process :+1:

      http://yveaux.blogspot.nl

      dbemowskD 1 Reply Last reply
      0
      • YveauxY Yveaux

        @dbemowsk great to hear!
        I hope I managed to explain to you how to get to these values, as you wanted to learn from the process :+1:

        dbemowskD Offline
        dbemowskD Offline
        dbemowsk
        wrote on last edited by
        #131

        @Yveaux Yes, I did learn from that. Thanks again.

        Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
        Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

        1 Reply Last reply
        0
        • nicofly974N Offline
          nicofly974N Offline
          nicofly974
          wrote on last edited by
          #132

          Hello
          A friend send me an old weather station in 868mhz, I want to hack it for using it in domoticz
          Your project is similar as I want, where can I find your code?
          Thank's

          dbemowskD 1 Reply Last reply
          0
          • nicofly974N nicofly974

            Hello
            A friend send me an old weather station in 868mhz, I want to hack it for using it in domoticz
            Your project is similar as I want, where can I find your code?
            Thank's

            dbemowskD Offline
            dbemowskD Offline
            dbemowsk
            wrote on last edited by
            #133

            @nicofly974 Unfortunately I put this on hold for a while as I have been having a bit of trouble with my power option for the node. I am actually working on a solar power setup with a small charge controller and a 2x18650 battery pack. The solar panel setup will be on a servo controlled solar tracker that I will run from a separate pro mini. My two issues right now are that I am having some issues with the charge controller, possibly user error. The other issue is designing and 3D printing the parts that will hold the charge controller, battery pack and tracker. If this cheap charge controller is an issue and I have to get a different one, it may alter my design. Shipping on this controller took forever to come on the boat from China.

            I haven't looked at my code for the sensors in a while, but maybe in the next day or two I'll post what I have with the understanding that it is in Alpha stage.

            Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
            Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

            dbemowskD 1 Reply Last reply
            0
            • dbemowskD dbemowsk

              @nicofly974 Unfortunately I put this on hold for a while as I have been having a bit of trouble with my power option for the node. I am actually working on a solar power setup with a small charge controller and a 2x18650 battery pack. The solar panel setup will be on a servo controlled solar tracker that I will run from a separate pro mini. My two issues right now are that I am having some issues with the charge controller, possibly user error. The other issue is designing and 3D printing the parts that will hold the charge controller, battery pack and tracker. If this cheap charge controller is an issue and I have to get a different one, it may alter my design. Shipping on this controller took forever to come on the boat from China.

              I haven't looked at my code for the sensors in a while, but maybe in the next day or two I'll post what I have with the understanding that it is in Alpha stage.

              dbemowskD Offline
              dbemowskD Offline
              dbemowsk
              wrote on last edited by
              #134

              @dbemowsk Here are some pics of the dual axis solar tracker that I am working on for the weather station. In the 4 corners are the CDS photo cells for the tracker.
              0_1510205656379_upload-a467911a-1ed7-4573-b114-e80d4e78e8d9
              0_1510205719255_upload-221b7633-4eef-4788-8814-4bbbfbb0a7ee
              0_1510205821046_upload-a7c4990e-8301-4d6b-940a-1700d9cb3942
              0_1510205877977_upload-e592dcb5-e2ac-4dcd-a3af-f47b4120bb39
              0_1510206015816_upload-f49898a9-d6c7-4c23-8575-dada20305400

              Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
              Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

              gohanG 1 Reply Last reply
              1
              • dbemowskD dbemowsk

                @dbemowsk Here are some pics of the dual axis solar tracker that I am working on for the weather station. In the 4 corners are the CDS photo cells for the tracker.
                0_1510205656379_upload-a467911a-1ed7-4573-b114-e80d4e78e8d9
                0_1510205719255_upload-221b7633-4eef-4788-8814-4bbbfbb0a7ee
                0_1510205821046_upload-a7c4990e-8301-4d6b-940a-1700d9cb3942
                0_1510205877977_upload-e592dcb5-e2ac-4dcd-a3af-f47b4120bb39
                0_1510206015816_upload-f49898a9-d6c7-4c23-8575-dada20305400

                gohanG Offline
                gohanG Offline
                gohan
                Mod
                wrote on last edited by
                #135

                @dbemowsk is the solar tracker really necessary?

                dbemowskD 1 Reply Last reply
                0
                • gohanG gohan

                  @dbemowsk is the solar tracker really necessary?

                  dbemowskD Offline
                  dbemowskD Offline
                  dbemowsk
                  wrote on last edited by
                  #136

                  @gohan Not sure, just thought it might be an addition that could maximize battery charging.

                  Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
                  Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

                  1 Reply Last reply
                  0
                  • gohanG Offline
                    gohanG Offline
                    gohan
                    Mod
                    wrote on last edited by
                    #137

                    it sure does, my question is if it is really needed. A lot depends on how much energy it uses :)

                    1 Reply Last reply
                    0
                    • nicofly974N Offline
                      nicofly974N Offline
                      nicofly974
                      wrote on last edited by
                      #138

                      Hello,

                      For a project wtih a fablab, we have using a Li-Polymer Charge Management Controllers MCP73831
                      You can have free "sample" for prototype if you ask directly to the factory, perhaps it could be faster.

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


                      20

                      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