How to monitor screen time for kids with Internet of Things – ESP8266 Arduino Tutorial

Almost 10,000 pediatricians joined the American Academy of Pediatrics national conference in October 2016 in order to discuss children’s health recommendations for the 2017. Key topics were children’s TV screen time, social media and cyber-bullying. The AAP experts recommend that for kids with age between 2 and 5 year, screen time should be limited to one hour per day. Little babies are most vulnerable to radiation and for them the screen time should be reduced to zero. But how can we monitor the screen time? Most of the TVs available don’t offer such an feature, not even Smart TVs don’t come with such an application. In this article I will teach you how to monitor TV screen time with Internet of Things simple low cost project.

Monitoring TV Screen Time with IoT ESP8266 WiFi module

Project overview and material requirements

This project is based on cheap WiFi module ESP8266 Arduino compatible device and requires low to medium programming and electronics knowledge. In order to complete this project your TV should have at least one USB port, very common feature nowadays on most available TVs.

If you haven’t worked with ESP8266 WiFi module, read here a complete review and tutorial about this device: ESP8266 Arduino Tutorial.

The project theory – how it works

99% of available TVs in our homes are equipped with USB and HDMIports as a standard feature. After doing a quick analysis, I found that almost all TVs do not supply current trough the USB port during the idle time (power off), which means that when you turn the TV on, you also supply current to any device that is plugged in the USB port.

Got the idea?

With this fact we will exploit the ESP8266 Arduino compatible device in order to measure the screen time. Whenever your kid will turn on the TV, he will also power on the WiFi module. We will program the ESP8266 to automatically connect to your internet router and send TV status to a online database (flow described in the following image).

Fixing the hardware parts

To be able to connect the ESP8266 WiFi device with your TV, you will need an USB ESP8266 programmer ready for plug and play. This device is an USB to serial converter (UART bridge) which has a CH340 chip integrated, dedicated for ESP-01 version. You will also use it to upload your code sketch into the ESP8266 WiFi micro-controller. It can be found over the internet at a price between 4$ and 9$ and it looks like this:

Connecting the ESP8266 WiFi device with the USB programmer is easy and natural. Just plug them together like in the following image:

Fixing the software part

After we setup the hardware devices, we need to program the ESP8266 module in order to record the screen time and send status to the internet of things database. Before we get into code sketch, you will need to create a free account on the www.thingspeak.com.

Note: Thingspeak.com is the most popular free IoT online platform which can collect and analyze the data from your Internet of Things projects.

After activating your account, you need to create a new Channel and setup at least 1 field to store the data from the ESP and also generate an API key. This API Key will be used in the Arduino code example to gain access when sending the HTTP request.

After finishing the Channel setup, place your home WiFi router credentials and the thingspeak API key in the next code example and upload it to the ESP8266 board.

Code logic explanation

Because I choosed the simplest method to accomplish the expected result, so that none-technical people can make it, we can only know when the TV is turned on. In order to know when the TV is turned OFF, the project should have an independent power supply, but let’s keep it simple. You can still get great results by using my logic.

So, to be able to calculate the screen time I configured the ESP8266 to send a status with value = 1, at every 60 seconds. In this way we don’t need the POWER OFF status, because we use the data to actually measure the minutes spent in front of the TV.

My TV example with Thingspeak graphs

If the TV is turned ON for one hour, in the database we should have 60 entries with value = 1. So if we sum the values from the last hour we will get exactly how many minutes the TV was ON. Below I will show you two graphic visualizations from the Thingspeak channel and what settings I used:

In the chart above you can see my TV status between 16:00 pm to 21:45 pm. Just for testing purpose I programmed the ESP8266 to send status at every 5 minutes until 19:45, and then at every 60 seconds. You can clearly see that big GAP between 20:00 and 20:37 which means that the TV was turned OFF. This is simple, the RED color means TV being turned ON and the gaps TV being turned OFF.

The graph presented above will tell you how many minutes your TV was on during all day long. To get that you will need to setup the chart to SUM all records during a day which is equivalent with how many requests were sent during all day. This chart tells me that during the current day my TV was ON for 148 minutes which is a very valuable information. You can see below visualization settings for this chart with the sum value set tot 1440 (total minutes during a day).Below you can see the how the graph shows the night shutdown interval. This graph shows measurements between 23 – 24 of December, with a large GAP during the night, and also a head to head minutes counter between both days in the second image.

Off course this project can be done in a more complex fashion. To get a better overview and accurate results we can use two ESP8266 modules, one hooked on TV, as a Web Server, and the other one as a Client. In this way we would be able to interrogate the TV status at any time, get a successful Server request when the TV is On or get a fail request when the TV is OFF because of the Server being down too.

Another way is to use a single ESP8266 with an independent power supply and measure the TV USB Vcc (+5V) as a logic signal with one of the available ESP GPIO. A step-down to 3.3 v should be used in the last example because of the ESP8266 digital input rated at 3.3v.

Conclusion

Being able to monitor TV screen time for my kid with less than 10$ makes me very happy. I actually exported the data from Thingspeak platform and imported in a MySQL database because I wanted to make some patterns in order to understand which intervals are trending. You don’t need to be a geek or a hobby passionate to make this project, your kids health is very important and screen time monitoring should be a priority for every parent.

If you found another way to monitor screen time please let us know below in a comment or on our facebook page.

Hoping that this article inspired you, i kindly invite you sharethis article, subscribe my YouTube channel and join the communities on social networks. Please feel free to comment or send suggestions / remarks so i can improve the content quality!

One Reply to “How to monitor screen time for kids with Internet of Things – ESP8266 Arduino Tutorial”

It’s an wonderful idea to keep track of the screen timings. It’s really useful and I tried the same with NodeMCU with Blynk notification to know whenever the TV is switched ON. I am trying to extend this to ask for switching OFF TV through Blynk when the ScreenTime crosses 2 hours or more…Thanks for your help.