If you enter a text message on a page opened on your smartphone, it will be sent from obniz via UART.
In this example, Mac is connected to the obniz, and the characters received from the smartphone is displayed on the Terminal.
"スマホで文字送信" is Japanese and in English means "sending text from your phone."
Materials- obniz Board
- mobile battery
- smartphone to open a browser
- PC to display characters
- tool to display characters such as Terminal
- interface to connect PC and obniz such as USB-Serial conversion cable
Hardware connection
Connect the obniz Board to PC as below.
obniz Serial conversion side 0 RX 1 TX 11 GND
Software
For detailed information of UART, refer to UART – obniz.
Program<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script
src="https://unpkg.com/obniz@3.x/obniz.js"
crossorigin="anonymous"
></script>
<script
src="https://code.jquery.com/jquery-3.4.1.js"
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"
></script>
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<title>Send Text Messages on UART</title>
</head>
<body>
<div class="container">
<h2 class="text-center" style="margin:40px">
Send Text Messages on UART
</h2>
<form id="messageform" class="text-center row">
<div class="col-xs-4 col-md-3"></div>
<div id="formarea" class="text-center col-xs-4 col-md-6">
<textarea id="textarea" name="text" rows="1" cols="20"></textarea>
<div class="text-center">
<button id="send" class="btn btn-success" style="margin:20px">
Send
</button>
</div>
</div>
<div class="col-xs-4 col-md-3"></div>
</form>
</div>
<script>
$(() => {
let obniz = new Obniz("OBNIZ_ID_HERE");
obniz.onconnect = async () => {
await obniz.uart0.start({ tx: 0, rx: 1, gnd: 11 });
$("#messageform").submit(async e => {
await e.preventDefault();
let message = $("#textarea").val();
await obniz.uart0.send(message + "\r\n");
$("#textarea").val("");
});
$(window).on("beforeunload", async e => {
await obniz.uart0.end();
await obniz.close();
return;
});
};
});
</script>
</body>
</html>
ExecuteIf you enter a text message on your smartphone and press “send, ” it will be received on your PC.
What is obniz?Before we get into the project, let's look into obniz.
Here → obniz for DIY electronics
obniz is a cloud-connected IoT development board. You can program on the web browser of any smartphone or computer and the command is sent to obniz through the internet via obniz cloud. By connecting the obniz to the cloud through wifi, users can remotely control devices that are physically connected to obniz.
Thanks to this cloud based approach, you can program with Python, Javascript, or other languages you prefer and control hardware directly. You don't need to integrate firmware into the device side. Recording and analyzing data is also easy with obniz cloud service.
Want to control hardware things with your current Python or Javascript skill? Want to start IoT project but don't know where to start? Want to learn programming with languages you prefer?
obniz will help you broaden your viewpoint and develop both your SW and HW skills.
For more information, please visit our official website → Official Website
Where to get obniz board? → Amazon /Official Store
Comments
Please log in or sign up to comment.