{"id":21212872,"url":"https://github.com/aureleq/pubnub-pycom-lightsensor","last_synced_at":"2025-10-15T11:08:57.299Z","repository":{"id":78009945,"uuid":"192511049","full_name":"aureleq/pubnub-pycom-lightsensor","owner":"aureleq","description":"Building a light monitoring system using PubNub and Pycom board","archived":false,"fork":false,"pushed_at":"2019-06-18T12:05:30.000Z","size":1135,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-14T23:43:17.289Z","etag":null,"topics":["clicksend","iot","pubnub","pycom"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aureleq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-18T09:42:08.000Z","updated_at":"2020-03-08T21:54:08.000Z","dependencies_parsed_at":"2023-07-03T03:52:01.908Z","dependency_job_id":null,"html_url":"https://github.com/aureleq/pubnub-pycom-lightsensor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aureleq/pubnub-pycom-lightsensor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aureleq%2Fpubnub-pycom-lightsensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aureleq%2Fpubnub-pycom-lightsensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aureleq%2Fpubnub-pycom-lightsensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aureleq%2Fpubnub-pycom-lightsensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aureleq","download_url":"https://codeload.github.com/aureleq/pubnub-pycom-lightsensor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aureleq%2Fpubnub-pycom-lightsensor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279075669,"owners_count":26097967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clicksend","iot","pubnub","pycom"],"created_at":"2024-11-20T21:12:16.491Z","updated_at":"2025-10-15T11:08:57.251Z","avatar_url":"https://github.com/aureleq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Building a light monitoring system using PubNub and Pycom board\n\nLight sensors can be used in various IOT applications: in smart cities to optimize street lighting, in home automation to control ambient light, or in safety related use cases to detect an opened door.\n\nIn this project, we will focus on cold chain monitoring, specifically refrigerator opening detection for energy saving. The goal is to alert users by text message if door stays opened for too long.\n\n## How it works\n\n![Diagram](img/diagram.PNG)\n\n[PubNub](https://www.pubnub.com) is a great fit to enable realtime communication for IOT devices and quickly deploy applications to trigger actions.\n\nOur sensor will measure and send light information (in lux) every minute to PubNub MQTT gateway. PubNub function will then be used to compare the lux value to assess an opened door (we consider a closed fridge as emitting no light). After 5 consecutive positive measurements, a message will be pushed to an alert channel and also by text message through [ClickSend service](https://www.clicksend.com).\n\nOur device is based on the [Pycom SiPy](https://pycom.io/product/sipy/) and [pysense](https://pycom.io/product/pysense/) boards. Pycom provides hardware to accelerate IOT development using multiple connectivity technologies like LoRa, Sigfox, WiFi or NB-IOT.\n\n![SiPy board](img/sipy.PNG)\n\nThe SiPy embeds an ESP32 micro-controller supporting Wi-Fi and Bluetooth as well as a Sigfox chipset. The Pysense is an extension board with several sensors: temperature, humidity, light, barometric and accelerometer.\n\n## Building the device\n\nRename first the file `config.json.example` to `config.json` and enter your wifi SSID information and PubNub publish key.\n\nYou can then transfer the content of directory `pycom` to your board. If this is your first time using the board, you can follow Pycom tutorial to [install their Pymakr plugin](https://docs.pycom.io/pymakr/installation/).\n\nThe board will blink green once connected to the wifi, and red when sending a measurement.\n\nLibraries in the folder lib/ are coming from [pycom repository](https://github.com/pycom/pycom-libraries).\n\n## PubNub function\n\nConnect to your PubNub admin interface and create a new module.\n\nWe can then create a new function that will execute `after publish` on channel `lighting`, content of the function is in file checkLuxValue.js.\n\n![Function checkLuxValue](img/checkLuxValue.PNG)\n\nThe function will publish to channel `lightingAlerts` once the lux threshold has been reached 5 times in a row (10 lux considered as low light environment). PubNub fire() could also have been used but publishing on a channel is also relevant for subscribers not receiving SMS.\n\nSecond function of the module also executes after publish but on channel `lightingAlerts`. It retrieves the clientId and sends a text message to the registered phone number.\nContent of the function is in file clicksendText.js. Enter your clicksend api key and phone number to complete it. You can create a free account on [ClickSend](https://www.clicksend.com).\n\n## Demo\n\nBelow is a simple demo of the device connecting to wifi and sending MQTT message:\n\n![Board GIF](img/demo.gif)\n\nAnd the received SMS after 5 positive measurements:\n\n![SMS](img/sms.JPG)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faureleq%2Fpubnub-pycom-lightsensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faureleq%2Fpubnub-pycom-lightsensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faureleq%2Fpubnub-pycom-lightsensor/lists"}