Hello guys,

I am planning to build a weather station as an electronics project. It is supposed to be a couple sensors (temperature, humidity, air quality for example) connected to a microcontroller (probably via I²C, because I’m currently interested in that and picked this project as an excuse to do something with it), and a basic LCD display to show the current data.

For this I want a small microcontroller that can collect the stats from the sensors and show them on the screen, so nothing too fancy. I want to actually deploy this on my balcony, so I don’t wanna sacrifice a Pi or something along those lines. Ideally something with a sleep mode so I can run it off a button cell. In order to use I²C and an LCD screen I would need around 9-13 pins, depending on the LCD. Plus some additional pins for buttons, means something with at least 16 GPIO pins would be desirable.

I was eyeing out something from the ATtiny family. Ideally it would be a through-hole-mounted chip as I want to use it on a breadboard first (and probably permanently). The only DIP chips are fairly old tho so I’m not sure if they’re easy to use nowadays. We used an ATtiny461A in university and had to program it via a Windows XP VM, which is an experience I would not like to relive.

I’m not afraid to get my hands dirty writing raw C code without an stdlib.

While the WiFi functionality of the ESP32 is appealing, I don’t know if I want to condemn one of them to a life on the balcony. I would rather use them for one-off projects instead and use something simpler for a long-term deployment.

The following are some ideas I have that I might want to add to my project later, but they’re just optional features and I don’t necessarily pick the microcontroller based on them:

  • Tracking/Logging sensor data over time, e.g. hourly. This would require some fairly accurate timing in order not to drift
  • Networking, so I can access the data via my local network

If there exist microcontrollers that fit my criteria I’d be happy to hear about them! I’m not an absolute beginner to electronics, but I’ve never shopped for microcontrollers before.

  • tofubl@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    8
    ·
    4 days ago

    If you need networking, go for the ESP32. There’s nothing easier or close that I know of, and incredibly cheap too. Downside is the power draw. If that is a concern and you really do want to run it off a coin cell for any prolonged time I’d say WiFi is out the window altogether, and I’d pick something efficient but more modern than an attiny, like any small arm cortex m0+ devboard or similar. If you want to experiment with low power radio, see what you can come up with with some lora transceivers.

    • Lauchmelder@feddit.orgOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 days ago

      Yeah, I think I’m gonna ignore networking for now. I’ll have a look at your recommendation, thank you!

      • Dave.@aussie.zone
        link
        fedilink
        English
        arrow-up
        3
        ·
        4 days ago

        Regarding wifi and power draw, you could always do batch uploading of data to another server at something like a 1:10 ratio, or upload only when there’s a change of more than 1 degree or similar.

        There are some low power deep sleep esp32 boards out there that can do like 3-6 months on a couple of AA batteries. A lot of power draw comes from hanging around on wifi doing dhcp, so having fixed addresses can cut down power usage considerably.

        Even without using the wifi side of things the esp32 boards come with lots of IO , plenty of drivers for various devices, and a reasonable in-house (i.e. not Arduino) development environment so I’d be leaning in that direction.

        You could also look at Sharp’s memory LCD as opposed to normal LCD, as that’s extremely low power without the fiddlyness of e-ink screens.

  • fonix232@fedia.io
    link
    fedilink
    arrow-up
    6
    ·
    4 days ago

    +1 on the ESP32.

    Very good support (incl Arduino framework which means tons of libraries for sensors), cheap, tons of variants of chips and dev boards for all sorts of purposes, plus if you buy a ready made module or dev board, you don’t need wireless certification (as those come with it).

    Tons of pins, tons of processing power, built in wireless support for WiFi, Bluetooth, Thread/Matter (depending on model).

    And you can utilise ESPHome if you want to go for a practically codeless deployment.

      • fonix232@fedia.io
        link
        fedilink
        arrow-up
        1
        ·
        3 days ago
        1. You can reduce CPU freq, disable unused features and even disable a whole ass core
        2. There’s this thing called sleep mode on ESP32 MCUs, you should probably use it 😉
        • czardestructo@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          3 days ago

          All fair points, assuming you write all your code yourself. But WiFi is still a pig even with optimization, coin cell is impossible which is what he/she asked to use.

    • Lauchmelder@feddit.orgOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 days ago

      Thank you for the advice, but it’s not really what I’m looking for. I am looking for something really lightweight for now, and the ESP32 is a bit overkill. And codeless deployment sounds horrible, I want to actually write the ode myself, I should have mentioned that!

      • AnyOldName3@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 days ago

        Unless you’re making thousands of something, an ESP32 is cheap enough that it shouldn’t matter whether or not it’s overkill. Getting something simpler will only save you a few pennies unless you’re overspending as ESP32 breakout boards are available for less than £2.

        The power draw will be a problem, though, unless you disable WiFi. They’re not really button-cell-friendly.

  • czardestructo@lemmy.world
    link
    fedilink
    English
    arrow-up
    3
    ·
    3 days ago

    If you want this to be powered by a coincell battery or any battery you need to figure out a power budget and pick a wireless protocol. WiFi is incredibly power hungry and won’t happen with a battery unless you like charging it every few days. If you are willing to make it a powered setup it will open many options otherwise youre stuck with zwave, ZigBee, BLE and LoRA. If you want to mix this project with other fun stuff like LoRa/meshtastic look into these. They snap into a main board and you can add a temp and humidity sensor and collect the data over BLE, add a screen and communicate over LoRa for miles. I can get these to run on a 18650 battery for about 3 weeks.

  • jeinzi@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    4 days ago

    If networking is the goal, choose any ESP32 module. If you want something simple akin to an ATtiny, ich can recommend the CH32V003. Is has plenty pins and an I²C peripheral, costs around 15 ct. For accurate timing, add an external oscillator instead of using the internal one.

    Edit: You could also use an external real time clock like the PCF8563, then you’d have an absolute datetime and wouldn’t need accurate timing on the microcontroller itself. The buy the CH32 (and anything else), I would choose lcsc.com

    • Lauchmelder@feddit.orgOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 days ago

      The suggestion of using an external clock module is so obvious, I don’t know how I didn’t come up with it myself. Thank you for that!

      • jeinzi@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 days ago

        I noticed that I glossed over your breadboard requirement. If you want to use something like an ATtiny or CH32, you could always buy some generic SMD breakouts like this. Both of these microcontroller series have internal oscillators and flash memories, so you really don’t need any external components. Maybe a bypass capacitor for good measure.

  • bitfucker@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 days ago

    There is a lot to unpack here. But my suggestion is “cheap” esp32 devboard. At least where I live, going with older / raw MCU (not a “devboard”) will ended up more expensive. I’ll give an example. The STM32F103C8T6 “Blue Pill” cost the same as ESP32 DOIT Devkit (around USD 3). BUT the bare MCU of both cost around 1-5 cent more due to the economy of scale. So unless you plan to design a custom board in bulk/size constraint, buying the devkit and making a daughter board can ended up cheaper