Inspiration

Home Sweet Home.
Ever since the pandemic started, people have been spending more time at home. Products like Alexa are making our home more smart and friendly, so we wanted to make something similar applying what we learned so far. On one hand, a smart home should make you comfortable, on the other hand, it must guarantee that you are safe. Thus, we set these two goals as our expected system functions.

What it does

We designed and prototyped an embedded device to demonstrate a Smart Home. Firstly, our product can sense the current temperature with a temperature and humidity sensor and automatically turn on a fan if it is hot. Secondly, our system uses a distance sensor to detect if there is a suspicious person approaching your door. Thirdly, our system can generate a random 6-bit password, then the user can input passwords from the keypad to open the door (shown by driving a servo motor).

How we built it

Hardware
For the hardware part, we designed our schematic and layout using Altium Studio, and then send to PCBWay for manufacturing. However, we didn't get our board on time because of the delay caused by covid pandemic. Alternatively, we used dev boards to build up a integrated system.
The temperature sensor SHTC3, distance sensor US-100, and RGB driver are connected to MCU as system input, and LEDs, fan, and servo motor serve as output to demonstrate our function.

Software
For the software part, we are using FreeRTOS to realize multi-thread logic. The bootloader is used to start up and update the program if possible, and the CLI command is used to test the functions.
The temperature sensor and distance sensor will constantly detect the environmental temperature, humidity and distance, and constantly transmit the data to the MQTT broker. The MQTT broker then sends the message to NodeRed UI frontend so that we can clearly see what’s happening on the website. Simultaneously, if the temperature is higher than the threshold, the MCU (Microcontroller Unit) will drive the fan to turn on, and if the distance is lower than the threshold we set, a red LED will be turned on to show an alert.
As for the keypad connected through I2C protocol, it allows users to input a 6 digits password to “open the door”. The password will be sent through MQTT, and then be compared with the correct password, which is generated by NodeRed random numbers.

Challenges we ran into

  1. The logic of FreeRTOS
    Both of us are not familiar with FreeRTOS. It took us a while to understand what’s the logic behind and how they work. Since we lack some operation system and computer architecture background, we spent some time trying to figure out how semaphore and mutex cooperate together to get multi threads running simultaneously. We learned a lot from the researching process and want to develop more knowledge in this field in the future.
  2. The usage of NodeRed
    When the project came to the stage that it needed to interact with the cloud, we were also confused. With the help of the professor and TAs, we made it clear how our sensors would communicate with the MQTT and NodeRed, which turned out to be quite an interesting process.
  3. Configuration of pins and PWM (Pulse-width Modulation) using ASF (Advanced Software Framework)
    We also met challenges when doing configuration for the pins on the dev board. It was confusing when referring to multiple datasheets and ASF, because each MCU is unique and needs a tailor. We were stuck on assigning the gpio pin to drive the fan, and on generating PWM waves to drive the servo. At last, thanks to detailed instruction from the professor, we successfully completed the overall project.

What we Learned with the prototype

From this course, we learned the overall process of building an IoT embedded system. This was really valuable experience as it gave us a clear picture of what we will be doing in the real industry in the future. From designing the system logic and picking the component, to drawing circuits and layout, and at last coding the embedded software, it added much color to our resume.
Looking back, hardware engineering has many uncertainties. For example, we need to check the market, again and again, to make sure the needed components are not out of stock. And when connecting the system, the noises and signal transmission efficiency need to be taken into consideration, so sometimes we were stuck in some annoying issue just because we used a long connecting wire. When communicating with cloud, the memory, heap, transmission frequency and speed affect the whole system a lot.
These are all valuable lessons we learned from the hands-on project.

What we learned

  • Used Altium to do circuit and layout design, generated manufacturing documentation.
  • Picked suitable and feasible components from the current market, checked BOM constantly, and monitored the manufacturing process.
  • Wrote I2C, USART drivers based on C codes.
  • Understood the working logic of FreeRTOS.
  • Designed NodeRed backend and frontend, understanding data transmission protocol on MQTT.
  • Learned firmware debugging tools in Atmel, used CLI command to test our system.

What's next for Smart Home

  1. Currently the data transmission is not stable enough. Limited to the memory, size of queue, and other unstable noise, our data sometimes would be blocked when sent to MQTT. Better transmission logic can be developed in the future.
  2. Due to the pandemic, we haven’t received our PCB yet, so we are building our system with dev boards and breadboards. After our PCB comes back, we will try to rebuild our system with the board designed fully by ourselves!
  3. In the future, this demo can be copied to a bigger platform, so that we can build a real smart home. For example, changing the fan to a real air conditioner at our home and the keypad to a real locker.

Built With

  • altiumstudio
  • atmelmicrochipstudio
  • c
  • samw25
  • seesaw
  • shtc3
  • us-100
Share this project:

Updates