Skip to content

Instantly share code, notes, and snippets.

View nkenna's full-sized avatar

Ugwumsinachi Nnadi nkenna

  • Abuja
View GitHub Profile
def getTemp():
global temperature
global humidity
global tt
hum, tempe = Adafruit_DHT.read_retry(sensormodel, sensorpin)
humidity = hum
humidity = float("{:0.2f}".format(humidity))
temperature = tempe
tt = tempe
temperature = float("{:0.2f}".format(temperature))
GPIO.setmode(GPIO.BCM)
# pins to use
pin_pir1 = 23
pin_pir2 = 26
alarm_pin = 21
flite_pin = 17
blite_pin = 27
slite_pin = 22
relay = 20
Padding(
padding: EdgeInsets.all(4.0),
child: Container(
width: 300,
height: 350,
child: WebView(
initialUrl: 'http://192.168.43.25:8000',
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text('Front Light'),
new Switch(
value: widget.toggleFL,
onChanged: (value){
setState(() {
widget.toggleFL = value; // toggle the button and its value
});
@override
void initState() {
// TODO: implement initState
super.initState();
Timer.periodic(Duration(seconds: 100), (timer) { //ask the server for humuidity value every 100 seconds
print('sending periodic message: hh');
widget.channel.sink.add('humidity'); // send message to server
setState(() {
humidity = humidd; // change the value of temperature with the recent result from server.
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
@nkenna
nkenna / pubspec.yaml
Created October 29, 2019 09:54
packages to install and download
name: iotcontrol
description: A new Flutter project.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
web_socket_channel: ^1.1.0
//make sure you have all this packages installed and imported
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:mqtt_client/mqtt_client.dart';
import 'package:web_socket_channel/io.dart';
import 'package:web_socket_channel/status.dart' as status;
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:webview_flutter/webview_flutter.dart'; //webview package to view remote camera feed
static void https_test()
{
char *msg = "080022380000008000009A00000530081329000001081329053020390013"; //already prepared 0800 mess
char buff[1024]={0};
char recv[1024]={0};
char *ip = "196.6.103.72"; //test ip
int port = 5043;
int ret = - 1;
int sock = 0;
char apn[32]="9mobile";
@nkenna
nkenna / test0800.c
Last active June 3, 2019 06:54
tried packing 0800 message but the date and time fields are giving issues.
void test0800() {
SDK_8583_ST8583 st_send_packet;
s32 len;
u8 temp[256];
//transmission date and time
u8 tmp[64];
u8 datetime[15];
u8 t_datetime[15] = {0};