2026年4月2日木曜日

paiza cloudで外部公開サーバを立てる方法(golang)

 PaizaCloud で Go 言語の HTTP サーバを立てて外部からアクセスできるようにするには、

「0.0.0.0」で待ち受けることと、PaizaCloud のポート公開設定を行う必要があります。

以下に手順とサンプルコードを示します。

1. Go HTTP サーバのサンプルコード

package main

import (
	"fmt"
	"log"
	"net/http"
)

// ハンドラ関数
func helloHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "Hello from Go HTTP Server on PaizaCloud!")
}

func main() {
	http.HandleFunc("/", helloHandler)

	// PaizaCloud では 0.0.0.0 で待ち受ける必要がある
	addr := "0.0.0.0:8080"

	log.Printf("Starting server on %s ...", addr)
	if err := http.ListenAndServe(addr, nil); err != nil {
		log.Fatalf("Server failed: %v", err)
	}
}

2. PaizaCloud 側の設定

  1. PaizaCloud のエディタで上記コードを作成(例: main.go)。
  2. ターミナルで以下を実行してビルド&実行:
    go run main.go
    
  3. PaizaCloud の右側メニューにある 「Port」または「公開ポート」設定 を開く。
  4. 8080 ポートを追加して公開する。
  5. 表示される 外部アクセス用 URL(例: https://<your-id>.paiza.....)にアクセスすると、ブラウザからサーバに接続できる。login-browerでurlを確認する!

3. 注意点

  • localhost や 127.0.0.1 では外部からアクセスできないため、必ず 0.0.0.0 を指定。
  • PaizaCloud の無料プランではサーバは一定時間で停止するため、長時間稼働には向きません。
  • HTTPS は PaizaCloud 側で自動的に付与されます(Go 側で TLS 設定不要)。

✅ この方法で、PaizaCloud 上の Go HTTP サーバを外部公開できます。

2026年3月29日日曜日

kaluma on ide 未踏あり!(ウィンドウズでも成功)

 

kaluma ide on chromeではconnectでピコとつないで左画面のコードがflashで書き込まれた! packageもいけるかどうかは、未踏。。。。
Total: 34 packages
  • npm i https://github.com/niklauslee/7-segment
    Kaluma library for multi-digit 7-segment display (aka. FND - flexible numeric display)
  • npm i https://github.com/niklauslee/active-buzzer
    Kaluma library to generate beep sound with active buzzer
  • npm i https://github.com/rossdoker/bh1750
    Kaluma library for BH1750 light sensor
  • npm i https://github.com/niklauslee/buzzer-music
    Kaluma library to play music with passive buzzer.
  • npm i https://github.com/niklauslee/dht
    Kaluma library for DHT humidity and temperature sensor 成功した!
  • github installしてreadmeの例文をindex.jsにしてkaluma flash ./index.js --bundleして
  • kaluma shell & .load で成功した
  • npm i https://github.com/rossdoker/ds1307
    Kaluma library for DS1307 RTC module
  • npm i https://github.com/niklauslee/esp8266-driver
    ESP8266 network device driver for Kaluma
  • npm i https://github.com/niklauslee/esp8266-http-client
    A simple Kaluma HTTP client library for ESP8266 module
  • npm i https://github.com/niklauslee/hc-sr04
    Kaluma library for HC-SR04 ultrasonic distance measurement module
  • npm i https://github.com/slashinfty/i2c-lcd
    Kaluma library for liquid crystal display with PCF8574 I2C port expander (LCM1602 module)
  • npm i https://github.com/niklauslee/ir-receiver
    Kaluma library for IR (Infra-red) receiver.
  • npm i https://github.com/niklauslee/joystick
    Kaluma library for joystick module
  • npm i https://gitlab.com/kobaj/kaluma-eink
    A library for controlling e-ink and e-paper displays (mostly from Waveshare) with Kaluma and an RP2040.
  • npm i https://github.com/niklauslee/lcd
    Kaluma library for liquid crystal display (HD44780 driver)
  • npm i https://github.com/niklauslee/lm35
    Kaluma library for LM35 temperature sensor
  • npm i https://github.com/AlexK-99/lp50xx
    This is an Kaluma library for interaction with the LP5009 and LP5012 constant current RGB driver from Texas Instrument
  • npm i https://github.com/niklauslee/max7219
    A library for MAX7219/MAX7221 (LED matrix)
  • npm i https://github.com/alexander-daniel/mcp3008
    Kaluma library for MCP3008 8-Channel ADC
  • npm i https://github.com/niklauslee/micro-jest
    A tiny testing framework for Kaluma
  • npm i https://github.com/niklauslee/mpu6050
    Kaluma library for MPU6050 6-axis motion sensor
  • npm i https://github.com/niklauslee/neopixel
    Kaluma library for NeoPixel (ws2812) based on RP2 PIO (Programmable I/O)
  • npm i https://github.com/niklauslee/pcd8544
    Kaluma library for PCD8544, a.k.a Nokia 5110 (Monochrome LCD Display)
  • npm i https://github.com/niklauslee/picosystem
    Kaluma library for Pimoroni's PicoSystem
  • npm i https://github.com/niklauslee/rotary-encoder
    Kaluma library for rotary encoder with a push switch (KY-040)
  • npm i https://github.com/niklauslee/servo
    Kaluma library to control servo motors
  • npm i https://github.com/niklauslee/simple-fonts
    Simple bitmap fonts for Kaluma :: モノクロOLEDでトライ!
  • npm i https://github.com/niklauslee/ssd1306
    Kaluma library for SSD1306 (Monochrome OLED Display)
  • npm i https://github.com/niklauslee/ssd1351
    Kaluma library for SSD1351 (16-bit Color OLED Display)
  • npm i https://github.com/niklauslee/st7735
    Kaluma library for ST7735 (Color TFT LCD Display)
  • npm i https://github.com/niklauslee/st7789
    Kaluma library for ST7789 (Color TFT/IPS LCD Display)
  • npm i https://github.com/niklauslee/stepper
    Kaluma library to control stepper motors
  • npm i https://github.com/niklauslee/tm1637
    Kaluma library for 7-segment LED Display
  • npm i https://github.com/haraldkubota/vl53l0x
    Time-of-Flight Sensor VL53L0X
  • npm i https://github.com/pankleks/picomqtt
    MQTT   一回は成功している。。。。
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
WSL2(Windows Subsystem for Linux 2)環境でKalumaJS(カルマJS)を動作させるための一般的な手順と注意点を解説します。KalumaJSは、Raspberry Pi Picoなどのマイコンボード向けに設計されたJavaScriptランタイムです。
WSL2でKalumaJSをセットアップする手順
  1. Node.jsのインストール (WSL2)
    KalumaJSはnpmを使用してインストールします。まず、UbuntuなどのWSL2ディストリビューションにNode.jsをインストールします。
    bash on wsl
    sudo apt update
    sudo apt install nodejs npm
    
  2. Kaluma CLIのインストール
    npm経由でKaluma CLIをグローバルにインストールします。
    bash on wsl
    sudo npm install -g kaluma
    
  3. USBシリアルポートの権限設定 (重要)
    WSL2はデフォルトでUSBデバイスに直接アクセスできません。Windows側のUSBシリアルポート(Pico)をWSL2に渡す必要があります。
    • USBIPD-WIN のインストール (Windows側): Windows上でターミナルを管理者権限で開き、以下を実行します。
      powershell
      winget install --interactive --exact dorssel.usbipd-win
      
    • Picoのバインド: USBでPicoを接続し、Windows側でポート番号を確認してバインドします。
      powershell
      usbipd list
      # PicoのBUSIDを確認 (例: 2-1)
      usbipd bind --busid 2-1
      usbipd attach --wsl --busid 2-1

      • WSL側でシリアルポート確認:
        bash
        ls /dev/ttyACM* これでttyACM0とでた!
        kaluma flash index.js --port /dev/ttyACM0で成功!